@Newfish_01 If s=')(*)', it will return False
at the first char.
Jianghan Li
@lee215
Posts made by lee215

RE: Python easy understand solution

RE: C++/Python Straight Forward Solution
@WJFQQQ
bfs is a list of nodes to search.if i.left: bfs.append(i.left)
if the current node has a left child, add this child node to the list and it will be parsed later. The same for right child.

RE: Python easy and concise solution
@zhongyuan9817
Thanks!
I like the replacement~i to (i + 1)
I reverse the string because it is very clear and efficient enough. 
RE: Simple 79 ms Python solution
@cesar0094
Make it shorter:def isPalindrome(self, s): s = [c.lower() for c in s if c.isalnum()] return s == s[::1]

RE: Cpp solution with explanation in details
@zhutou7
I review the problem statement and it is0 < nums[i] < 10000
now. 
RE: Python solution
@shengaotang I added some explanation and it will help. Tell me if I am not clear enough.

Python easy and concise solution
def findShortestSubArray(self, nums): c = collections.Counter(nums) first, last = {}, {} for i, v in enumerate(nums): first.setdefault(v, i) last[v] = i degree = max(c.values()) return min(last[v]  first[v] + 1 for v in c if c[v] == degree)

Python solution
I used two list to take note of the current state.
If you read question 218. The Skyline Problem, you will easily understand how I do this.pos
tracks the xcoordinate of start points.
height
tracks the ycoordinate of lines.def fallingSquares(self, positions): height = [0] pos = [0] res = [] max_h = 0 for left, side in positions: i = bisect.bisect_right(pos, left) j = bisect.bisect_left(pos, left + side) high = max(height[i  1:j] or [0]) + side pos[i:j] = [left, left + side] height[i:j] = [high, height[j  1]] max_h = max(max_h, high) res.append(max_h) return res