So smart. Maybe changing i, j, k to left, cur, right will be more readable. The "virtual index" is quite hard for me. Like I have no idea when the question comes to "nums[0] > nums[1] < nums[2] > nums[3]...." instead of "nums[0] < nums[1] > nums[2] < nums[3]...." what is the "virtual indexing" then?
zhlinh
@zhlinh
Posts made by zhlinh

RE: O(n)+O(1) after median  Virtual Indexing

RE: Short Python / Ruby / C++
Thanks, actually my fault. I thought it's min
(
k, len(nums1)+1)
, so I wanted to fix to min(
k+1, len(nums1)+1)
, which equals to min(
k, len(nums1))
+ 1. Your solution is so concise. 
RE: Short Python / Ruby / C++
In python solution "The last two lines can be combined, but I find it rather ugly and not worth it:
for i in range(max(klen(nums2), 0), min(k, len(nums1))+1))", isn't it "for i in range(max(klen(nums2), 0), min(k+1, len(nums1))+1))"? 
RE: Summary of 4 different solutions (BFS, DP, static DP and mathematics)
In Static Dynamic Programming maybe Using m to record cntPerfectSquares.size() will be better.
m = cntPerfectSquares.size(); while ( m <= n) { ... cntPerfectSquares.push_back(cntSquares); m += 1; }

RE: [bucket sort] JAVA solution with explanation, O(N) time and space
The gap being in one bucket is fine. Because at least one bucket is empty, it doesn't change the maxGap result.

RE: My really simple Java O(n) solution  Accepted
Res should init with 0, for the case that nums is null.

RE: Share two similar Java solution that Accpted by OJ.
Maybe in solution 1 "dict.add(end)" should go before for (String string:dict) ... ladder.put(string, Integer.MAX_VALUE). Ladder should contain end, isn't it?
In solution 2, Using visited instead of queue can avoid duplicate queue insertion well, just in the end of while q loop add q = visited. 
RE: My concise C++ solution, AC 90 ms
OK, It works well. Cool.