283Move Zeroes  
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.

angledark0123 發表在 痞客邦 留言(0) 人氣()

92Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.

angledark0123 發表在 痞客邦 留言(0) 人氣()

13. Roman to Integer

Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.

angledark0123 發表在 痞客邦 留言(0) 人氣()

173. Binary Search Tree Iterator
 
這題題意有點模糊,一開始我作成preorder sort 還過了 

angledark0123 發表在 痞客邦 留言(0) 人氣()

 29Divide Two Integers
Divide two integers without using multiplication, division and mod operator.
If it is overflow, return MAX_INT.

angledark0123 發表在 痞客邦 留言(0) 人氣()

33Search in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).

angledark0123 發表在 痞客邦 留言(0) 人氣()

3Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring"pwke" is a subsequenceand not a substring.
 
這題不是用DP,因為一但遇到重疊的基本上counting是直接歸零
看解答也是用two pointer 掃過所有可能,l 負責記錄開頭,r 負責記錄結尾,
用兩個紀錄的好處是當要清除重複的字元時,前面非重複字元其實也要從set清除掉,
所以 l 可以幫助紀錄到底需要清掉哪些字元,中間過程中我們會掃過所有可能的不重複字串,
所以要有一個int 去記錄這之中最長的字串在最後return

angledark0123 發表在 痞客邦 留言(0) 人氣()

360. Sort Transformed Array
注意這題之所以變難是因為O(n),因為不能用sorting,不然會變成O(nlogn)
用到的概念是數學的概念拋物線

angledark0123 發表在 痞客邦 留言(0) 人氣()

通常用來detect loop,判斷從哪段開始有loop 
解法可以想像是龜兔賽跑,兔子兩倍速,烏龜一倍速前進
 
假設c是起點距離loop的距離,k是起點距離第一次相遇點的距離,loop 長度是L

angledark0123 發表在 痞客邦 留言(0) 人氣()

 
162. Find Peak Element

A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.

angledark0123 發表在 痞客邦 留言(0) 人氣()

211. Add and Search Word - Data structure design

Design a data structure that supports the following two operations:
void addWord(word)
bool search(word)

angledark0123 發表在 痞客邦 留言(0) 人氣()

在研究為什麼 List<List<Integer>> res = new ArrayList<>(); 
 為什麼可以這樣初始,然後研究到這個
 

angledark0123 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。