码迷,mamicode.com
首页 >  
搜索关键字:leetcode 19    ( 34993个结果
[LeetCode]Remove Element
Remove Element...
分类:其他好文   时间:2014-05-23 02:10:01    阅读次数:230
leetcode Remove Nth Node From End of List
题目说:Try to do this in one pass 只用一遍遍历的话,p1先走n节点,p2再走,等到p1到达链表尾的时候p2正好在倒数第n+1个上面鸟 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode...
分类:其他好文   时间:2014-05-23 01:52:29    阅读次数:331
LeetCode: Permutations [045]
【题目】 Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 【题意】 给定一个数组,生成所有的全排列 【思路】 递归,类DFS...
分类:其他好文   时间:2014-05-23 01:08:26    阅读次数:194
【leetcode】Max Points on a Line
题目:给定二维坐标上的若干点,找出这样一条线,属于该线的点数最多,返回点数。 分析:两个点确定了一条直线。共线,说明斜率相同。那么确定一个点A,该点与其他的点就会生成不同的斜率。这些斜率中,会存在相同的,那么这些相同的斜率就说明他们跟A在同一条直线上。 这里我们把斜率分成两种,一种是正常的斜率,就是可以写成 y = kx + b形式的k;一种就是横坐标相同,纵坐标不相同的,这时的斜率为无穷大。...
分类:其他好文   时间:2014-05-23 00:43:16    阅读次数:301
LeetCode: Wildcard Matching [043]
【题目】 Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). The functi...
分类:其他好文   时间:2014-05-23 00:17:12    阅读次数:364
[LeetCode]Remove Duplicates from Sorted Array
Remove Duplicates from Sorted Array...
分类:其他好文   时间:2014-05-22 23:06:48    阅读次数:271
【leetcode】Reverse Words in a String
问题:给定一个字符串,字符串中包含若干单词,每个单词间由空格分隔,将单词逆置,即第一个单词成为最后一个单词,一次类推。 说明:字符串本身可能包含前导空格或后导空格,单词间可能包含多个空格,要求结果中去掉前导和后导空格,单词间空格只保留一个。 与rotate函数类似,先逆置每个单词,再将所有字符串逆置。 void reverseWords(string &s) { if(s.si...
分类:其他好文   时间:2014-05-22 18:49:26    阅读次数:249
LeetCode: Permutations II [046]
【题目】 Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1]. 【题意】 给定一个候选数集合,候选集中可能存在重复数,返回所有的排列 【思路】 ...
分类:其他好文   时间:2014-05-22 17:32:17    阅读次数:247
leetcode 3Sum 3Sum Closest 4Sum
这几个题很典型也是国外一些知名公司经常会问到的题 3Sum: 排序,避免重复,时间复杂度O(n^2) class Solution { public: vector > threeSum(vector &num) { int len=num.size(); sort(num.begin(),num.begin()+len);...
分类:其他好文   时间:2014-05-22 17:25:02    阅读次数:259
LeetCode: Jump Game II [044]
【题目】 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of ju...
分类:其他好文   时间:2014-05-22 17:02:20    阅读次数:244
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!