解法一:不好的解法
double Power(double base,int exponent)
{
double result=1.0;
for(int i=1;i
result*=base;
return result;
}
解法一没有考虑指数为0和负数的情况,只考虑了指数为正数的情况。
解法二:全面但...
分类:
其他好文 时间:
2015-07-07 19:39:28
阅读次数:
87
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.
Input:Digit string “2...
分类:
其他好文 时间:
2015-07-07 19:36:09
阅读次数:
152
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
和N-Queens 同样的解法。class Solution {
public:
int totalNQueens(int n...
分类:
其他好文 时间:
2015-07-07 19:35:23
阅读次数:
135
本文从代码形式,常用方式,相关概念,调用关系和比较分析,这5个维度浅析 exit 与 return 在C++的相同点与区别。现阐释如下。...
分类:
编程语言 时间:
2015-07-07 19:31:20
阅读次数:
148
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given "25525511135",
return ["255.255.11.135", "255.255.111.35"]. (Order ...
分类:
其他好文 时间:
2015-07-07 19:30:43
阅读次数:
116
return 的作用是退出循环体所在的函数,相当于结束该方法。
break 的作用是结束循环,跳出循环体,执行后面的程序。
continue 的作用是结束此次循环,进行下一次循环;...
分类:
其他好文 时间:
2015-07-07 19:28:58
阅读次数:
169
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = “aab”,
Return
[...
分类:
其他好文 时间:
2015-07-07 19:28:43
阅读次数:
116
题目:Given 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 not...
分类:
其他好文 时间:
2015-07-07 19:17:16
阅读次数:
128
#include int sum(int x,int y){ return x+y;}void printNum(int x){ //判断x的值 if (x>0) { printf("%d\t",x); }else{ printf("0\t"); ...
分类:
编程语言 时间:
2015-07-07 19:07:14
阅读次数:
155
Contains DuplicateGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at leas...
分类:
其他好文 时间:
2015-07-07 18:50:10
阅读次数:
118