Thursday, November 17, 2016

My Simple Summary on Leetcode Problems

My Summary

Tree Related Problem:
1) Recursive solution is always first choice
2) Inorder traversal is useful

For numeric questions, be aware of cases where input might be INTEGER.MAX_VALUE, INTEGER.MIN_VALUE, and abs(INTEGER.MIN_VALUE) =  INTEGER.MAX_VALUE + 1

And also the case where number might be positive or negative.

Tuesday, August 30, 2016

Maximum Product Subarray

Maximum Product Subarray


Code Ganker's post: http://blog.csdn.net/linhuanmars/article/details/39537283?locationNum=1
The local and global variable is very interesting and useful. Key point is that local max should be max(A[i], local[i-1] + A[i]). If A[i] is even larger than previous local max + A[i], then itself should be local max instead.

My answer: