Implement int sqrt(int x).Compute and return the square root of x.线性查找会TLE。用二分查找。注意溢出的处理。全部都改成long long. 1 class Solution { 2 public: 3 int sqrt(i...
分类:
其他好文 时间:
2014-07-27 10:41:02
阅读次数:
181
《LYFvs2013转vs2010》1.修改解决方案文件(**.sln) 将------------------------------------------------------------- Microsoft Visual Studio Solution File, Format Ve.....
分类:
其他好文 时间:
2014-07-27 10:37:42
阅读次数:
254
Reverse Words in a String考虑几个特殊的情况1.若字符窜s=" "2.字符窜s=“a b d e”3.字符窜s=“ a”class Solution {public: void reverseWords(string &s) { int i; int c...
分类:
其他好文 时间:
2014-07-26 17:03:01
阅读次数:
360
一开始想DP一步步迭代更新,求出到跳到最后一个的最小步数,但是时间复杂度O(nk),会超时。
再一想,发现该题只需要返回能否到达最后一个,不需要最小步数,所以迭代时候只需要保留当前能够走到的最远距离tmpMax,时间复杂度降到O(n)。
class Solution {
public:
const int MAXVALUE = 1 << 30;
bool canJump(int A[],...
分类:
其他好文 时间:
2014-07-26 15:30:51
阅读次数:
210
class Solution {
public:
const int MAXVALUE = 1 << 30;
int findMinStepToIndex(int maxNumbers[],int maxSteps,int index)
{
if (index == 0)
return 0;
int left = 1;
int right = maxSteps;...
分类:
其他好文 时间:
2014-07-26 15:30:01
阅读次数:
170
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321 1 class Solution { 2 public: 3 int reverse(int x){ 4 ...
分类:
其他好文 时间:
2014-07-26 13:54:24
阅读次数:
206
SubsetsGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must...
分类:
其他好文 时间:
2014-07-26 01:34:56
阅读次数:
189
1..检查版本2.版本升级console#upgradesystemftp:A:Addressornameofremotehost[]:192.168.1.10Sourcefilename[]:FTOS-SC-8.3.3.9.binUsernametologinremotehost:dellPasswordtologinremotehost:01:59:11:%STKUNIT0-M:CP%FTP-3-FTP_ERROR:Filenotfound%Error:Failedtoaccessther..
分类:
其他好文 时间:
2014-07-24 18:02:46
阅读次数:
298
1.hashMap方法O(n)空间换时间public class Solution { public int[] twoSum(int[] numbers, int target) { HashMap hash=new HashMap(); int ans[]=ne...
分类:
其他好文 时间:
2014-07-23 22:20:57
阅读次数:
262
Nothing to hard to think. Just take care of boundary conditions.class Solution {public: string convert(string s, int nRows) { if(s.empty() |...
分类:
其他好文 时间:
2014-07-23 15:04:36
阅读次数:
227