对一个数组,将数组中偶数从大到小排序,奇数从小到大排序,奇数和偶数交叉着放且输出数组第一位放奇数,若奇数和偶数不等长,则把剩下的直接放到数组中。#include#include#includeusing namespace std; bool cmp(int &a,int &b){ return ....
分类:
其他好文 时间:
2014-06-28 09:37:42
阅读次数:
127
题目
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,
[1,1,2] have the following unique permutations:
[1,1,2], [1,2,1],
...
分类:
其他好文 时间:
2014-06-27 23:53:21
阅读次数:
290
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm sho...
分类:
其他好文 时间:
2014-06-27 22:24:34
阅读次数:
346
Now, instead outputting board configurations, return the total number of distinct solutions.
分类:
其他好文 时间:
2014-06-27 11:40:13
阅读次数:
277
Given an array of strings, return all groups of strings that are anagrams.
分类:
其他好文 时间:
2014-06-27 11:34:57
阅读次数:
641
escape.py# -*- coding: utf8 -*-import sysif type('') is not type(b''): def u(s): return s bytes_type = bytes unicode_type = str bas...
分类:
编程语言 时间:
2014-06-27 11:10:20
阅读次数:
480
很裸的polya,不过我看polya看了很久
吉大ACM模板里面也有
#include
#include
#include
using namespace std;
long long gcd(long long a,long long b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
#ifndef ONLINE_JUDGE
//...
分类:
其他好文 时间:
2014-06-27 10:46:11
阅读次数:
181
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is d...
分类:
其他好文 时间:
2014-06-27 10:18:32
阅读次数:
151
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.
Return all such possible sentences.
For example, given
s = "...
分类:
其他好文 时间:
2014-06-27 09:23:00
阅读次数:
220
题目
Given an unsorted integer array, find the first missing positive integer.
For example,
Given [1,2,0] return 3,
and [3,4,-1,1] return 2.
Your algorithm should run in O(n) time and u...
分类:
其他好文 时间:
2014-06-27 08:30:30
阅读次数:
202