摘要: Given two arrays, write a function to compute their intersection. Example 1: Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [4,9] Exam 阅读全文
posted @ 2018-12-03 13:27 fatttcat 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2018-12-03 12:27 fatttcat 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and num 阅读全文
posted @ 2018-12-02 18:52 fatttcat 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. In Pascal's trian 阅读全文
posted @ 2018-12-02 18:32 fatttcat 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers 阅读全文
posted @ 2018-12-02 17:30 fatttcat 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant d 阅读全文
posted @ 2018-12-02 15:46 fatttcat 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 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. Example: Note: 用 阅读全文
posted @ 2018-12-02 15:16 fatttcat 阅读(99) 评论(0) 推荐(0) 编辑
摘要: An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A[j]. A 阅读全文
posted @ 2018-12-02 15:02 fatttcat 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 用binary search 如果A[mid] < A[mid+1],说明peak在mid右侧,l = mid + 1;否则说明peak在mid右侧,r = mid 时间:O(N),空间:O(1) 阅读全文
posted @ 2018-12-02 12:10 fatttcat 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文
posted @ 2018-12-02 10:02 fatttcat 阅读(126) 评论(0) 推荐(0) 编辑