有关peak的、或者3个什么东西的,尝试遍历 the middle index.

DP题目:先想brute force,想想怎么用recursion做,然后想怎么用iteration来做,然后想怎么用caching的方式来optimize。最后想到底几个数字需要被cache?比如如果是fib,其实只有上两个数字需要被cache。

找那种连续多少个连着xxx的subarray的基本上都可以用sliding window来做。具体方法是:先移动右边一直到找到满足的为止,然后开始移动左边,直到不再满足,就又开始移动右边。这种办法一般来说是最time efficient的。O(n)就可以。或者说可以用某种map/array,把结果放在里面然后遍历那个map本身。这种一般来说给的数字range会比较小,类似100 — 10000之间。

Self Testing Questions

  1. Why is React efficient?
  2. how do you declare a variable in React?
  3. What are something that you cannot use for naming an attribute in React? and Why? What is an alternative name?
  4. What do you do when you have a JSX element that is single tag? (self closing)
  5. How do…

The purpose is to find successor of a node on a binary tree (Inorder). One thing special about this problem is that we are given the parent node for each node.

I started by simply traversing through the tree and record all the node and store them in an arrayList…

my own solution

Again, the logic that head is not null and head.next is not null so that ans = head.next else return head can be shorten to if head is null or head.next is null then we return head. And then we continue with ans = head.next. this is again a logic problem that can be simplified.

We will use LeetCode 76 minimum window substring as an example for the sliding window kinds of problem analysis.

Sliding Window questions go like this:

there will be 2 pointers. First, the left pointer does not move, the right pointer keep going until it finds the first substring(or whatever) that…

a mistakes I made that should be remembered:

when we found a solution I should remember to left++ and right — — otherwise its in an infinite loop.

Arnold

"What if I fall?" "Oh my darling, but what if you fly?"

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store