Skip to content

Solution to lintcode contests #1

@new-one-one-one

Description

@new-one-one-one

Hi there ,
Can you help me with a problem
https://www.lintcode.com/problem/meeting-room-iv/description
This question I solved using dp by finding maximum length of non-overlapping interval giving priority to maximum value
below is my python code.
But it only passed up 31% , can you provide some hints whats going wrong?

class Solution:
   def maxValue(self, meeting, value):
        intervals=meeting
        if not meeting:
            return 0
        l=len(intervals)
        intervals.sort()
        res=value[0]
        tune=[[intervals[0][1], value[0]]]
        for i in range(1,l):
            temp=value[i]
            for j in range(i):
                if tune[j][0]<=intervals[i][0]:
                    temp=max(value[j]+value[i], temp)
            tune.append([intervals[i][1], temp])
            res=max(tune[i][1], res)
        return res

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions