different answers between test case and run time


  • 0
    K

    Hi
    I found my code gives different answers between test case and run time.
    This is for test case [[1,4],[2,5]].
    Could someone please throw some light here?
    0_1489388736358_Capture2.PNG

    '''

    class Solution(object):

    def merge(self, intervals):
        if intervals == []: return []
        if len(intervals) == 1: return intervals
        intervals.sort()
        ret = []
        cur = intervals[0]
    
        for i in range(1, len(intervals)):
            s = intervals[i].start
            e = intervals[i].end
            if cur.end < s:
                ret.append(Interval(cur.start,cur.end))
                cur.start = s
                cur.end = e
            else:
    
                cur.end = max(e, cur.end)            
    
        return ret + [cur]
    

    '''


  • 0
    P

    Facing the same issue here. Could anyone point out as to why this is happening?


  • 0
    P

    0_1490131675905_Screen Shot 2017-03-21 at 2.26.43 PM.png

    0_1490131711960_Screen Shot 2017-03-21 at 2.28.19 PM.png


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.