摘要: Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2014-10-20 21:43 supernigel 阅读(172) 评论(0) 推荐(0) 编辑
摘要: Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文
posted @ 2014-10-20 19:47 supernigel 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 首先,学习一下罗马数字,参考罗马数字罗马数字是最古老的数字表示方式,比阿拉伯数组早2000多年,起源于罗马罗马数字有如下符号:基本字符IVXLCDM对应阿拉伯数字1510501005001000计数规则: 相同的数字连写,所表示的数等于这些数字相加得到的数,例如:III = 3小的数字在大的数字右边... 阅读全文
posted @ 2014-10-20 14:43 supernigel 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i... 阅读全文
posted @ 2014-10-17 19:26 supernigel 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings.这个很简单,看代码便知// LongestCommonPrefix.cpp : 定义控制台应用程序的入口点。//#include... 阅读全文
posted @ 2014-10-17 18:52 supernigel 阅读(116) 评论(0) 推荐(0) 编辑
摘要: // 3SumClosest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include#include #include using namespace std;class Solution {public: int threeSumClo... 阅读全文
posted @ 2014-10-16 21:11 supernigel 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 类似3Sum,先排序,这后两重for循环,然后对最后的一个数组设两个指针遍历。这里注意重复的问题,例如第一重如果和前面一个数相同则跳过,因为前面的查找肯定包含了本次的情况。// 4Sum.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #inclu... 阅读全文
posted @ 2014-10-16 16:24 supernigel 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 思路: 1.将数组排序, 2.a 遍历 数组a[0]....a[n-1]; 3.当 a=a[i] 时 后面的问题 就是 : a[i+1] 到 a[n-1]中 b+c =-a (编程之美2.12 快速寻找满足条件的两个数 ) 记 b=a[j]=a[i... 阅读全文
posted @ 2014-10-16 14:22 supernigel 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are som... 阅读全文
posted @ 2014-10-02 00:42 supernigel 阅读(139) 评论(0) 推荐(0) 编辑
摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文
posted @ 2014-10-02 00:34 supernigel 阅读(167) 评论(0) 推荐(0) 编辑