码迷,mamicode.com
首页 >  
搜索关键字:leetcode 19    ( 34993个结果
LeetCode OJ - Restore IP Addresses
这道题采用穷举法。 1 /** 2 * Given a string containing only digits, 3 * restore it by returning all possible valid IP address combinations. 4 ...
分类:其他好文   时间:2014-05-08 09:17:22    阅读次数:248
LeetCode:Insert Interval
题目链接Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were ini...
分类:其他好文   时间:2014-05-08 08:40:51    阅读次数:367
Leetcode: Roman to Integer
一次通过: 1 public class Solution { 2 public int romanToInt(String s) { 3 int sum = 0; 4 int[] num = new int[s.length()]; 5 if...
分类:其他好文   时间:2014-05-08 08:24:26    阅读次数:233
Leetcode | Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:其他好文   时间:2014-05-08 06:33:29    阅读次数:339
Leetcode: String to Integer
抠细节的题目,很多次过,特别是 Integer.MIN_VALUE 与 Integer.MAX_VALUE的绝对值并不一样大 1 public class Solution { 2 public int atoi(String str) { 3 int result=0; 4...
分类:其他好文   时间:2014-05-08 05:44:17    阅读次数:343
LeetCode:Merge Intervals
题目链接Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].对若干...
分类:其他好文   时间:2014-05-08 05:21:42    阅读次数:334
leetcode第一刷_Populating Next Right Pointers in Each Node
这道题之前没见过,一上来还真不知道怎么做。问题的限制条件,树是完全二叉树其实并不是关键,只不过是一个简化的条件而已。那关键是什么呢?如何从当前节点跳到下一个开始的节点。我的做法是,每次从一层的最左边节点开始,一层一层的走。其实只有两种形式的next指针需要我们来更新,第一种,同一个节点的左右孩子,第二种,父亲相邻时,左边父亲的右孩子和右边父亲的左孩子之间。完全二叉树的简化就体现在更新的过程,因为完...
分类:其他好文   时间:2014-05-08 04:02:43    阅读次数:324
leetcode第一刷_Triangle
很简单的一道DP,看到空间限制是O(N)的,不要习惯性的以为是要保存每一行的最小值,不难想到是要保存一行当中各个数为路径终点时的和的大小。当算到最后一行时,就是从顶部到底部以这个底部位置为终点的最短路径和,找一个最小的就可以了。 实现的时候要注意个问题,因为计算时要用到上一行的数据,所以为了避免数据被覆盖,应该从后往前算,这个技巧用的很多,相信大家都很熟悉。 ac代码如下: class So...
分类:其他好文   时间:2014-05-08 04:01:44    阅读次数:282
Combinations
combination 的6种解法...
分类:其他好文   时间:2014-05-08 02:10:56    阅读次数:305
LeetCode Word Break II
class Solution {private: vector result;public: vector wordBreak(string s, unordered_set &dict) { vector > dp; result.clear(); ...
分类:其他好文   时间:2014-05-08 01:00:03    阅读次数:361
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!