原创 2.1.17 Plus One

Link: https://oj.leetcode.com/problems/plus-one/ Given a non-negative number represented as an array of digits, plus o

原创 2.1.11 Remove Element

Link: https://oj.leetcode.com/submissions/detail/9751364/ 這題應該很簡單,但沒過。再做。 我的思路: 先對數組排序,然後找到element。//不需要這樣做。 Approach I

原创 2.1.14 Valid Sudoku

Link: https://oj.leetcode.com/problems/valid-sudoku/ 這題簡單,基本一次過。不用再做。 Time: O(3*n^2), n=9 注意:循環時用:for(int j = 0; j < bo

原创 2.1.18 Climbing Stairs

Link: https://oj.leetcode.com/problems/climbing-stairs/ You are climbing a stair case. It takes n steps to reach to th

原创 2.1.10 4Sum

Link: https://oj.leetcode.com/problems/4sum/ Given an array S of n integers, are there elements a, b, c, and d in S su

原创 2.1.16 Rotate Image

Link: https://oj.leetcode.com/problems/rotate-image/ You are given an n x 

原创 2.1.15 Trapping Rain Water

Link: https://oj.leetcode.com/problems/trapping-rain-water/ Given n non-negative integers representing an elevation ma

原创 2.2.2 Reverse LinkedList II

Link: https://oj.leetcode.com/problems/reverse-linked-list-ii/ Reverse a linked list from position m to n. Do it in-pl

原创 2.1.8 3Sum

Link: https://oj.leetcode.com/problems/3sum/ 這題和2sum差不多,但“使用哈希表的解法並不是很方便,因爲結果數組中元素可能重複,如果不排序對於重複的處理將會比較麻煩”//? Ref:http:

原创 15.14 Text Justification

Link: https://oj.leetcode.com/problems/text-justification/ Given an array of words and a length L, format the text suc

原创 15.13 Divide Two Integers

Link: https://oj.leetcode.com/problems/divide-two-integers/ My thought: subtract divisor from dividend.  public class

原创 2.1.2 Remove Duplicates from Sorted Array II

Link: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ Follow up for "Remove Duplicates": What

原创 2.1.1 Remove Duplicates from Sorted Array

Link: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/ Given a sorted array, remove the duplicate

原创 2.1.6 Longest Consecutive Sequence

Link: https://oj.leetcode.com/problems/longest-consecutive-sequence/ Given an unsorted array of integers, find the len

原创 2.1.5 Median of Two Sorted Arrays

Link: https://oj.leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays A and B of size m and n