码迷,mamicode.com
首页 >  
搜索关键字:problems    ( 6275个结果
[Leetcode] Longest Consecutive Sequence 略详细 (Java)
题目参见这里https://leetcode.com/problems/longest-consecutive-sequence/这个题目我感觉很难,看了半天别人写的答案,才明白个所以然。下面的代码是我自己的改编,写的好像很复杂的样子,主要也是为了方便自己理解,耐着性子看完,应该就理解了。【个人分析...
分类:编程语言   时间:2015-04-30 10:25:48    阅读次数:113
[LeetCode]-007-String to Integer (atoi)
网址:https://leetcode.com/problems/string-to-integer-atoi/ 题意: 字符串转int数 分析: 经典题,主要需要注意输入中,允许先有空格,再来内容. 内容可能还不是整齐和规则的... 解法: 1.遍历空格 2.判断正负号 3.读数字 4.可能存在结尾号 代码: https://github.com/LiLane/leetc...
分类:其他好文   时间:2015-04-30 01:06:40    阅读次数:143
leetcode - House Robber
leetcode -house-robberhttps://leetcode.com/problems/house-robber/Q:You are a professional robber planning to rob houses along a street. Each house has...
分类:其他好文   时间:2015-04-29 23:19:17    阅读次数:148
[LeetCode]-007-Reverse Integer
网址:https://leetcode.com/problems/reverse-integer/ 题意: 反转数字,正负不变. 分析: 思路显而易见, 重点在有些刁钻的输入输出上. 解法: 因为无视正负,又要用到mod. 自然想到abs... 不过abs对于int并不完全适用. 使用前,判断一下是不是INT_MIN或Integer.MIN_VALUE 我又不想记住这个正负,...
分类:其他好文   时间:2015-04-29 19:49:22    阅读次数:129
ubuntu 'Unable to correct problems, you have held broken packages' 错误
在用apt 安装软件时,有时会用国内的源以加快下载速度。但是在使用ubuntu 14.04的过程中,这一过程可能会导致错误“Unable to correct problems, you have held broken packages”。 经测试,网上的apt-get install -f, a...
分类:系统相关   时间:2015-04-29 16:31:54    阅读次数:3441
LeetCode(1)--Two Sum
原题: https://leetcode.com/problems/two-sum/Given an array of integers, find two numbers such that they add up to a specific ta...
分类:其他好文   时间:2015-04-29 00:40:14    阅读次数:165
[LeetCode]-005-Longest Palindromic Substring
网址:https://leetcode.com/problems/longest-palindromic-substring/ 题意: 找出最长回文字符串. 解法1: 自然是暴力枚举,把每一个元素从中间往左右遍历,如果是且是最长的存下字符串. 比如abccba. 定位元素是2->c. 找左1->b.不行 找右3->c.可以->找左右同时->找左右同时 找左右同时.不行 思路就是...
分类:其他好文   时间:2015-04-28 22:56:08    阅读次数:218
[LeetCode]-006-ZigZag Conversion
网址:https://leetcode.com/problems/zigzag-conversion/ 题意: 转换一种编码格式?类似于这种意思吧... 反正挺无聊的一题...找规律...模拟题 分析: 特别注意以下numRows等于1和字符串长度小于numRows 解法: 按照行列来划分,常规的就是满列, 非常规的就是每隔(numRows)就存在的(多余)值 代码: http...
分类:其他好文   时间:2015-04-28 22:53:50    阅读次数:177
Flatten Binary Tree to Linked List Total Accepted: 45093 Total Submissions: 156588
题目来自于LeetCode https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ Given a binary tree, flatten it to a linked list in-place. For example, Given 1 ...
分类:其他好文   时间:2015-04-28 21:07:40    阅读次数:137
[LeetCode]-004-Median of Two Sorted Arrays
网址:https://leetcode.com/problems/median-of-two-sorted-arrays/ 题意: 给了两组有序数,找出他们总的中位数 提示: 中位数是左右相等数目数的值,如果不存在,则取左右相等数目数的两个数的平均值. 解法1: 把两组数合并成一组数.也可以是O(m+n). 但空间复杂度是O(m+n). 明显有更好的解法. 解法2: 因为两组数...
分类:其他好文   时间:2015-04-28 21:06:58    阅读次数:119
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!