随笔分类 -  leetcode 总结

(leetcode题解)Can I Win
摘要:In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach o 阅读全文

posted @ 2017-06-30 15:56 kiplove 阅读(368) 评论(0) 推荐(0)

(leetcode题解)Range Sum Query - Immutable
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Note: 题意是给定一个数组返回给定位置之间的元素的和。 这道题如果只求单独 阅读全文

posted @ 2017-06-16 21:14 kiplove 阅读(197) 评论(0) 推荐(0)

(leetcode题解)Contains Duplicate
摘要:Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at lea 阅读全文

posted @ 2017-06-12 21:22 kiplove 阅读(210) 评论(0) 推荐(0)

(leetcode题解)Maximum Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, 阅读全文

posted @ 2017-06-12 20:08 kiplove 阅读(185) 评论(0) 推荐(0)

(leetcode题解)Two Sum II - Input array is sorted
摘要: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 @ 2017-06-11 22:43 kiplove 阅读(173) 评论(0) 推荐(0)

(leetcode题解)Pascal's Triangle
摘要:Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 题意实现一个杨辉三角。 这道题只要注意了边界条件应该很好实现 阅读全文

posted @ 2017-06-11 22:06 kiplove 阅读(162) 评论(0) 推荐(0)

(leetcode题解)Shortest Unsorted Continuous Subarray
摘要:Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be 阅读全文

posted @ 2017-06-11 21:21 kiplove 阅读(265) 评论(0) 推荐(0)

(leetcode题解)Max Consecutive Ones
摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length 阅读全文

posted @ 2017-06-11 20:18 kiplove 阅读(201) 评论(0) 推荐(0)

(leetcode题解)Third Maximum Number
摘要:Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexi 阅读全文

posted @ 2017-06-11 19:59 kiplove 阅读(154) 评论(0) 推荐(0)

(leetcode题解)K-diff Pairs in an Array
摘要:Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an inte 阅读全文

posted @ 2017-06-09 20:04 kiplove 阅读(201) 评论(0) 推荐(0)

(leetcode题解)Remove Duplicates from Sorted Array
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文

posted @ 2017-06-09 15:41 kiplove 阅读(136) 评论(0) 推荐(0)

(leetcode题解)Can Place Flowers
摘要:Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they 阅读全文

posted @ 2017-06-08 21:09 kiplove 阅读(744) 评论(0) 推荐(0)

(leetcode题解)Reshape the Matrix
摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. 阅读全文

posted @ 2017-06-08 19:52 kiplove 阅读(247) 评论(0) 推荐(0)

(leetcode题解)Search Insert Position
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文

posted @ 2017-06-08 16:51 kiplove 阅读(145) 评论(0) 推荐(0)

(leetcode题解)Array Partition I
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文

posted @ 2017-06-07 19:42 kiplove 阅读(174) 评论(0) 推荐(0)

(leetcode题解)Merge Sorted Array
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size tha 阅读全文

posted @ 2017-06-07 16:41 kiplove 阅读(157) 评论(0) 推荐(0)

(leetcode题解)Top K Frequent Elements
摘要:Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assum 阅读全文

posted @ 2017-06-07 15:51 kiplove 阅读(196) 评论(0) 推荐(0)

导航