- 博客(8)
- 收藏
- 关注
原创 【Leetcode】Remove Element #27
Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new length. 题
2015-08-17 07:58:34 255
原创 【Leetcode】Gas Station #134
没有想出来,查阅后发现题目思路很巧妙,详见:http://www.programcreek.com/2014/03/leetcode-gas-station-java/ 美中不足的是fact1的证明网上很少或者说不是很流畅,但是自己也写不出好的证明 class Solution { public: int canCompleteCircuit(vector& gas, vector
2015-08-17 03:44:11 255
原创 【Leetcode】 First Missing Positive #41
Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses consta
2015-08-16 09:04:13 236
原创 【Leetcode】Longest Common Prefix #14
Write a function to find the longest common prefix string amongst an array of strings. 最长的common prefix肯定是随着比较的增加不断减少的,所有设max_common_length_possible, 每次比较最多不会超过这个数,比较完后再update此数值。 class Solution { p
2015-08-16 03:33:58 221
原创 【Leetcode】PlusOne #66
很简单,不多说 class Solution { public: vector plusOne(vector& digits) { int i = digits.size() - 1; int cur = 1; while(cur && i != -1) { int temp = digits[i] + cur;
2015-08-16 03:08:42 356
原创 【Leetcode】Edit Distance #72
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word:
2015-08-10 09:13:03 365
原创 【Leetcode】Binary Tree Right Side View #199
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For example: Given the following binary tree, 1
2015-08-10 02:27:32 248
原创 【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 for another array, you must do this in place with
2015-08-02 04:58:53 153
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人