@Kerr.L Got it! Thanks a lot!
Posts made by leiyama001
RE: Easy to understand Python solution using in-order traversal
nice solution! Can you explain the time complexity of this solution?
Python Solution using priority queue but cannot pass some test cases
My solution using priority queue cannot pass test case like [[9,10],[4,9],[4,17]]
The result should be 2 but I returned 3, can anyone tell me how to fix this bug?
Thanks so much!
def minMeetingRooms(self, intervals): """ :type intervals: List[Interval] :rtype: int """ if intervals is None or len(intervals) == 0: return 0 intervals.sort(key = lambda x : x.start) pq =  pq.append(intervals.end) for i in range(1, len(intervals)): if intervals[i].start >= pq[-1]: pq.pop() pq.append(intervals[i].end) return len(pq)
Why my backtracking solution doesn't have "add, recurse, remove" routine?
def letterCombinations(self, digits): if not digits or len(digits) == 0: return  res =  self.DFS(digits, 0, "", res) return res def DFS(self, digits, cur, result, results): if len(result) == len(digits): results.append(result) return # backtracking else: for chr in self.digit2letters[digits[cur]]: self.DFS(digits, cur + 1, result + str(chr), results)
This is my DFS solution using the backtracking thought. I just a little confused about the backtracking method in different problem. Why some of them need to first add one temptation and then recursion and then remove that temptation to go back to previously step. But why this problem don't need to do so?
Anyone wants to explain this in detail? Thanks so much
RE: Concise Python solution using BFS, O(n) time and O(n) space
nice solution! thanks!
But I wonder what's the time complexity difference of pop() operation between list and deque
why my code doesn't work with problem "Line 28: Exception: Type <type 'type'>: Not implemented"
Why my code doesn't work?
Please help me:
def reverseWords(self, s):
:type s: str
if not s or len(s) == 0:
list = s.split(' ') ans =  for i in range(len(list)-1, -1, -1): if list[i] != ' ': ans.append(list[i]) return " ".join(ans)