自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(147)
  • 收藏
  • 关注

原创 nautilus

这是一个简单命令,但是容易忘,mark在这里:)

2015-12-18 13:46:42 1574

原创 [GIT].gitconfig配置

[core] editor = vim excludesfile = ~/system-config/.git-exclude[color] ui = auto[user] name = wangqianchuang email = [email protected][alias]

2015-12-01 14:48:46 764

转载 欢迎使用CSDN-markdown编辑器

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦: Markdown和扩展Markdown简洁的语法 代码块高亮 图片链接和图片上传 LaTex数学公式 UML序列图和流程图 离线写博客 导入导出Markdown文件 丰富的快捷键 快捷键 加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl

2015-12-01 14:45:56 456

原创 [PowerManagerService]经验总结, 手机不灭屏以及手机无法点亮的常见原因

1, 手机不灭屏的常见原因分析。 2, 手机无法点亮的常见原因分析。 先占坑, 后面再写。

2015-02-12 21:32:44 1282

原创 关于FileLock

mark两篇文章 http://android.toolib.net/reference/java/nio/channels/FileLock.html http://android.toolib.net/reference/java/nio/channels/FileLock.html

2014-09-04 19:05:45 1671

原创 [leetcode刷题系列]Median of Two Sorted Arrays

看代码,猜算法~ class Solution { public: /** * th is 0-based */ int find(int *a, int n, int *b, int m, int th){ if(n == 0) return b[th]; if(m == 0)

2013-09-30 13:18:36 1283 1

原创 [leetcode刷题系列]Gas Station

嗯,这是leetcode最新加的一道题目, 也是很经典的算法类的题目了。解法也不止一种。 这里写一下利用双端队列怎么做这道题求出所有的合法的起点把。 const int MAXN = 1e5 + 10; int head, tail; int deq[MAXN << 1]; int n; int data[MAXN << 1], sum[MAXN << 1]; class S

2013-09-29 23:38:17 1505

原创 [leetcode刷题系列]4Sum

囧, 就在3sum上面的基础上改一下就好了 class vector_int_hash{ const static int P = 10007; const static int MOD = 1e9 + 7; public: size_t operator() (const vector &v)const{

2013-08-16 18:54:14 835

原创 [leetcode刷题系列]3Sum Closest

- - 开始写模糊了- n^2复杂度 class Solution { public: int threeSumClosest(vector &num, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function

2013-08-16 18:46:51 705

原创 [leetcode刷题系列]3Sum

循环枚举前两个, 然后二分查找第三个,嗯, 用hash_map判重 class vector_int_hash{ const static int P = 10007; const static int MOD = 1e9 + 7; public: size_t operator() (const vector &v)const{

2013-08-16 18:31:19 651

原创 [leetcode刷题系列]Combination Sum II

- - 继续暴力把 class Solution { void dfs(vector> &vp, int p, int target, vector & stk, vector > & ans){ if(target == 0){ ans.push_back(stk); ret

2013-08-16 00:46:43 646

原创 [leetcode刷题系列]Combination Sum

暴力就好了- -leetcode上面的题目就是暴力 class Solution { void dfs(vector&v, int p, int target, vector & stk, vector > & ans){ if(target == 0){ ans.push_back(stk);

2013-08-16 00:35:41 666

原创 [leetcode刷题系列]ZigZag Conversion

嗯, 模拟题- -  class Solution { public: string convert(string s, int nRows) { // Start typing your C/C++ solution below // DO NOT write int main() function if(nRows ==

2013-08-15 23:40:24 705

原创 [leetcode刷题系列]String to Integer (atoi)

没啥好说的额 class Solution { public: int atoi(const char *str) { // Start typing your C/C++ solution below // DO NOT write int main() function while(*str != 0){

2013-08-15 23:29:07 634

原创 [leetcode刷题系列]Sort Colors

题目虽然简单, 但是确实找了好一会的bug,对着数据- - 这题值得再写一遍。 class Solution { public: void sortColors(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() functi

2013-08-15 00:28:15 688

原创 0813leetcode刷题总结

最近几天工作忙, 因为又要发新版本了。 所以今天只做这三道。 而且这三道在leetcode上应该算是比较有价值的了。 不过都还算简单。  有空的话Minimum Window Substring这道题还值得再写一边:) 明天继续吧

2013-08-14 00:59:32 959

原创 [leetcode刷题系列]Minimum Window Substring

这个也许算是two pointer类型的题目。  先贴一个简单的版本, 这个的复杂度应该算是256 * n class Solution{ bool ok(int* a, int * b){ for(int c = 0; c < (1 << 8); ++ c) if(a[c] < b[c]) return fals

2013-08-14 00:38:09 730

原创 [leetcode刷题系列]Word Search

暴力dfs搜索就行了, 应该没什么好的算法 const int MAXN = 100 + 10; const int dx[] = {-1, 0, 0, 1}; const int dy[] = {0, -1, 1, 0}; int n, m; int is[MAXN][MAXN]; bool dfs(int r, int c, int p, vector > & board, st

2013-08-13 23:56:26 649

原创 [leetcode刷题系列]Scramble String

这题也没说数据规模, 一开始按照100来的。 跑大数据的时候TLE了。 于是怀疑是不是每次初始化花太多时间了 所以就改成了50就过了- -,大概是n^4的算法, 有点暴力了。 不知道有没有其他更好的 const int MAXN = 50 + 5; string s1, s2; int dp[MAXN][MAXN][MAXN]; int get(int st1, int st2,

2013-08-13 23:43:25 689

原创 0812leetcode刷题总结

囧, 发第八篇的代码的时候, 又说超过了20篇, 只能保存为草稿, 明天再发了  今天刷了8道, 还剩下24道, 接下来每天刷8道, 到周四就刷完咯- -输完后应该会这对不同类型的遇到的问题总结下, 这样比较有价值一些。 今天刷的8道里面比较有价值的大概是两道,一道是 Text Justification,之所以说这道比较有价值倒不是说这个的算法有多难。 而是这是一道模拟题-

2013-08-13 00:10:38 852

原创 [leetcode刷题系列]Recover Binary Search Tree

这题目以前还真没做过, 这种题在acm中基本上没办法考察, 要求常数空间神马的 第一次见到的时候, 没想到好的算法, 放弃了, 然后今天决定剩下不到30道leetcode题目要挨个刷, 再次见到这个题目, 只有硬着头皮上了。想了一会其实就想到了。 可见遇到不会的还是要仔细想下- - 其实不难。 对于这道题,我们可以中序遍历这棵树, 然后每次访问一个节点的时候就把它的值表示到一个全局变

2013-08-13 00:10:26 730

原创 [leetcode刷题系列]Decode Ways

dp一下就好了 const int MAXN = 1e6 + 10; int dp[MAXN]; class Solution { bool ok(char c){ return c >= '1' && c <= '9'; } bool ok(char a, char b){ if(a == '1') re

2013-08-12 22:27:19 634

原创 [leetcode刷题系列]Subsets II

递归暴力枚举就好了- - vector > data; class Solution { void dfs(int cur, vector & stk, vector > &ret){ if(cur >= data.size()){ ret.push_back(stk); re

2013-08-12 22:18:30 584

原创 [leetcode刷题系列]Text Justification

- - 模拟题, 不过写的时候要仔细, 而且要理解好题意, 其实不难。 不过我写的时候因为没理解好题意,一开始写错了- -, 每行的单词之间至少要有一个空格的。这点特别注意, 其他就没啥了 class Solution { string getString(vector &words, int st, int en, int L){ // special

2013-08-12 21:46:27 972

原创 [leetcode刷题系列]Word Ladder II

这题时间卡的还真是严啊- -  先bfs一遍,标记没个单词属于哪一层, 然后从end开始往回走,就好了 string start, end; unordered_map lev; void dfs(string now, vector & stk, vector > & ret){ if(now == start){ vector tmp(stk);

2013-08-12 21:16:35 796

原创 [leetcode刷题系列]Surrounded Regions

囧, 这题用dfs我re了,应该是爆栈了。 于是改成了bfs就过了 const int MAXN = 1000 + 10; const int dx[] = {-1, 0, 0, 1}; const int dy[] = {0, -1, 1, 0}; int n, m; bool vis[MAXN][MAXN]; void bfs(int r, int c, vector > &

2013-08-12 19:51:01 566

原创 [leetcode刷题系列]Palindrome Partitioning II

n^2的预处理求出那些子串是回文的,哪些不是, 然后再n^2的dp。 const int MAXN = 2500; int n; bool is[MAXN][MAXN]; int dp[MAXN]; class Solution { public: int minCut(string s) { // Start typing your C/C++ solutio

2013-08-12 19:31:19 556

原创 [leetcode刷题系列]Palindrome Partitioning

暴力枚举 const int MAXN = 1000 + 10; string s; int is[MAXN][MAXN]; bool isPl(int left, int right){ if(left >= right) return true; int& ret = is[left][right]; if(ret != -1)

2013-08-12 19:12:33 548

原创 0811leetcode刷题总结

回顾了一下- -发现都是简单题, 没事啥好总结的。- - 脑袋晕晕的,今天就到这把 明天继续:) 已经100道了, 还差32道题目

2013-08-12 15:38:04 630

原创 [leetcode刷题系列]Trapping Rain Water

- - 嗯, 水题 const int MAXN = 1e6 + 10; int dleft[MAXN], dright[MAXN]; class Solution { public: int trap(int A[], int n) { // Start typing your C/C++ solution below // DO NOT w

2013-08-12 15:37:58 518

原创 [leetcode刷题系列]Anagrams

表示不是很清楚这题要 干嘛- - class Solution { public: vector anagrams(vector &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function map> hash;

2013-08-12 15:37:46 599

原创 [leetcode刷题系列]Search in Rotated Sorted Array II

- - 这题反正我是没想到确定性的logn的算法。 我的解法最坏情况下是O(n) class Solution { public: bool search(int A[], int n, int target) { // Start typing your C/C++ solution below // DO NOT write int main(

2013-08-12 15:37:39 493

原创 [leetcode刷题系列]Simplify Path

- - 模拟题 class Solution { vector splite(string s){ vector vs; int last = -1; for(int i = 0; i < s.size(); ++ i){ if(s[i] == '/'){ if(i - las

2013-08-12 15:37:32 624

原创 [leetcode刷题系列]Climbing Stairs

- - 这其实是斐波拉契数列 class Solution { int fib[100]; public: int climbStairs(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function fib[0]

2013-08-12 15:36:53 498

原创 [leetcode刷题系列]Plus One

- - 模拟题 class Solution { public: vector plusOne(vector &digits) { // Start typing your C/C++ solution below // DO NOT write int main() function if(digits.size() <= 0)

2013-08-12 15:36:43 507

原创 [leetcode刷题系列]Unique Paths II

现在他是一个dp题- - const int MAXN = 100 + 10; int n, m; int dp[MAXN][MAXN]; int getAns(int r, int c, vector > & grid){ int & ret = dp[r][c]; if(ret != -1) return ret; if(grid[r][c

2013-08-12 15:36:33 491

原创 [leetcode刷题系列]Unique Paths

dp一下就行- - 其实这是一个组合数学题,答案是C(m - 1 + n - 1, m - 1) const int MAXN = 100 + 10; int dp[MAXN][MAXN]; class Solution { public: Solution(){ memset(dp, 0xff, sizeof(dp)); for(int i =

2013-08-12 15:36:20 493

原创 [leetcode刷题系列]Spiral Matrix II

- - 基本上和上一道一样的道理 const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; int n; vector > ans; void dfs(int r, int c, int p, int number){ ans[r][c] = number; for(int i = 0; i < 4

2013-08-12 15:36:10 478

原创 [leetcode刷题系列]Spiral Matrix

- - 模拟题 const int MAXN = 1000; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; int n, m; int vis[MAXN][MAXN]; vector ans; vector > matrix; void dfs(int r, int c, int p){ vis

2013-08-12 15:35:53 479

原创 [leetcode刷题系列]Length of Last Word

水题- -不过通过这个题意识到了const的一种用法。以前不太了解这个。 就是const指针和指向const对象的指针的写法和区别 class Solution { public: int lengthOfLastWord(const char *s) { // Start typing your C/C++ solution below //

2013-08-12 15:35:43 541

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除