leetcode summary 08/29

107. Binary Tree Level Order Traversal II use element as index to record whether visit 117. Populating Next Right Pointers in Each Node II child connected and be used for next level 646 Maximum Length of Pair Chain DP: pairs[i][0] > pairs[j][1]? dp[j] + 1 : dp[j] greedy: for end point z, if all intervals where end point < z, there is no possible to get a longer chain based on previous intervals.

leetcode summary 08/27

51. N-Queens dfs: each recursion check with previous rows quick check: using a boolean array to record if current location is conflicts with elements in col, \ and / bit mask: set i to 1: a |= (1 << i) set i to 0: a &= ~(1 << i) inverse i: a ^= (1 << i) get i: (a >> i) & 1 find last 1: a & -a 52.

Core Java 读书笔记

http://docs.oracle.com/javase/tutorial/ Core Java Ch4 Objects and Classes 4.1 Introduction to Object-Oriented Programming Encapsulation: The key to making encapsulation work is to have methods never directly access instance fields in a class other than their own. 4.2 Using Predefined Classes an object variable doesn’t actually contain an object. It only refers to an object. 4.3 Defining Your Own Classes, page 145 4.4 Static Fields and

leetcode summary 08/24

250. Count Univalue Subtrees tc: O(n) sc: O(n) terminal case: null -> True every node: whether left subtree equals val, and right subtree equals val. Only true, count + 1. refer