- 博客(147)
- 收藏
- 关注
原创 [GIT].gitconfig配置
[core] editor = vim excludesfile = ~/system-config/.git-exclude[color] ui = auto[user] name = wangqianchuang email = wangqianchuang@smartisan.com[alias]
2015-12-01 14:48:46 783
转载 欢迎使用CSDN-markdown编辑器
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2015-12-01 14:45:56 490
原创 [PowerManagerService]经验总结, 手机不灭屏以及手机无法点亮的常见原因
1, 手机不灭屏的常见原因分析。2, 手机无法点亮的常见原因分析。先占坑, 后面再写。
2015-02-12 21:32:44 1350
原创 关于FileLock
mark两篇文章http://android.toolib.net/reference/java/nio/channels/FileLock.htmlhttp://android.toolib.net/reference/java/nio/channels/FileLock.html
2014-09-04 19:05:45 1698
原创 [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 1297 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 1515
原创 [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 841
原创 [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 718
原创 [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 659
原创 [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 658
原创 [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 674
原创 [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 723
原创 [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 641
原创 [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 697
原创 0813leetcode刷题总结
最近几天工作忙, 因为又要发新版本了。 所以今天只做这三道。而且这三道在leetcode上应该算是比较有价值的了。 不过都还算简单。 有空的话Minimum Window Substring这道题还值得再写一边:)明天继续吧
2013-08-14 00:59:32 972
原创 [leetcode刷题系列]Minimum Window Substring
这个也许算是two pointer类型的题目。 先贴一个简单的版本, 这个的复杂度应该算是256 * nclass 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 744
原创 [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 659
原创 [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 698
原创 0812leetcode刷题总结
囧, 发第八篇的代码的时候, 又说超过了20篇, 只能保存为草稿, 明天再发了 今天刷了8道, 还剩下24道, 接下来每天刷8道, 到周四就刷完咯- -输完后应该会这对不同类型的遇到的问题总结下, 这样比较有价值一些。今天刷的8道里面比较有价值的大概是两道,一道是 Text Justification,之所以说这道比较有价值倒不是说这个的算法有多难。而是这是一道模拟题-
2013-08-13 00:10:38 863
原创 [leetcode刷题系列]Recover Binary Search Tree
这题目以前还真没做过, 这种题在acm中基本上没办法考察, 要求常数空间神马的第一次见到的时候, 没想到好的算法, 放弃了, 然后今天决定剩下不到30道leetcode题目要挨个刷,再次见到这个题目, 只有硬着头皮上了。想了一会其实就想到了。 可见遇到不会的还是要仔细想下- - 其实不难。对于这道题,我们可以中序遍历这棵树, 然后每次访问一个节点的时候就把它的值表示到一个全局变
2013-08-13 00:10:26 764
原创 [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 644
原创 [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 595
原创 [leetcode刷题系列]Text Justification
- - 模拟题, 不过写的时候要仔细, 而且要理解好题意, 其实不难。 不过我写的时候因为没理解好题意,一开始写错了- -,每行的单词之间至少要有一个空格的。这点特别注意, 其他就没啥了class Solution { string getString(vector &words, int st, int en, int L){ // special
2013-08-12 21:46:27 1011
原创 [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 815
原创 [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 584
原创 [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 565
原创 [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 558
原创 0811leetcode刷题总结
回顾了一下- -发现都是简单题, 没事啥好总结的。- - 脑袋晕晕的,今天就到这把明天继续:) 已经100道了, 还差32道题目
2013-08-12 15:38:04 643
原创 [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 527
原创 [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 604
原创 [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 502
原创 [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 632
原创 [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 509
原创 [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 518
原创 [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 501
原创 [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 504
原创 [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 492
原创 [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 486
原创 [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 552
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人