swift reversed = sorted(names, { (s1: String, s2: String) -> Bool in return s1 > s2 }) java8 list.sort((a, b) -> { Integer.compare(a.length(),b.length() }); C++ sort(x,x + N,[](float a, float b) { ...
分类:
编程语言 时间:
2015-06-09 17:54:47
阅读次数:
138
functionsecondsToTime(time,forceHours){
varhours=Math.floor(time/3600)%24,
minutes=Math.floor(time/60)%60,
seconds=Math.floor(time%60),
result=((forceHours||hours>0)?(hours<10?‘0‘+hours:hours)+‘:‘:‘‘)+(minutes<10?‘0‘+minutes:minutes)+‘:‘+(secon..
分类:
其他好文 时间:
2015-06-09 17:37:55
阅读次数:
155
L51: N-Queens
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that
no two queens attack each other.
Given an integer n, return all distinct solutions to the n-qu...
分类:
其他好文 时间:
2015-06-09 17:32:04
阅读次数:
140
public class SqList {
private int[] data;
private int length;
public SqList() {
data = new int[30];
length = 0;
}
public boolean empty() {
return length == 0;
}
public int length() {...
分类:
编程语言 时间:
2015-06-09 17:29:11
阅读次数:
145
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
方法:找1...n中每个数因式分解中,5的个数(5的个数一般大于2的个数),即为10的个数
注意:题目要求时间复杂度:...
分类:
其他好文 时间:
2015-06-09 17:23:55
阅读次数:
110
题意:汶川地震买大米
分析:裸多重背包,这题数据比较小所以可以三重循环不需要优化
代码:
#include
#include
using namespace std;
int dp[1000][1000],t,n,m;
int p[1000],h[1000],c[1000];
int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
ci...
分类:
其他好文 时间:
2015-06-09 17:22:15
阅读次数:
146
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 numbers such that they add up to the target, where in...
分类:
其他好文 时间:
2015-06-09 17:12:28
阅读次数:
97
//获取元素属性function getStyle(obj, attr) { return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, 0)[attr];}//运动函数function doMove(obj, a...
分类:
Web程序 时间:
2015-06-09 16:52:24
阅读次数:
133
没有重载 将函数名想象为指针,也有助于理解为什么ECMAScript中没有函数重载的概念。funcrion addSomeNumber(num){ return num+100; }function addSomeNumber(num){ return num+200; }var resu...
分类:
其他好文 时间:
2015-06-09 16:45:12
阅读次数:
96
题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.代码:class Solution {public: int div...
分类:
其他好文 时间:
2015-06-09 16:31:20
阅读次数:
97