2017年6月12日

(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 阅读(175) 评论(0) 推荐(0) 编辑

2017年6月11日

(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 阅读(165) 评论(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 阅读(155) 评论(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 阅读(259) 评论(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 阅读(185) 评论(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 阅读(141) 评论(0) 推荐(0) 编辑

2017年6月9日

(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 阅读(192) 评论(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 阅读(114) 评论(0) 推荐(0) 编辑

2017年6月8日

交换操作 swap

摘要: 一个类定义一个swap函数通常需要一次拷贝和两次赋值 例如 A类的两个对象v1与v2交换 A temp=v1; //copy构造一个临时对象 v1=v2; //赋值运算 v2=temp; //赋值运算 如果采用指针交换则可以减少一次拷贝构造 A* temp=v1; v1=v2; //赋值运算 v2= 阅读全文

posted @ 2017-06-08 22:29 kiplove 阅读(799) 评论(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 阅读(728) 评论(0) 推荐(0) 编辑

导航