- 博客(141)
- 资源 (10)
- 收藏
- 关注
原创 Practice Round APAC test 2017——Problem D. Sums of Sums
ProblemAlice presented her friend Bob with an array of N positive integers, indexed from 1 to N. She challenged Bob with many queries of the form "what is the sum of the numbers between these tw
2016-10-14 09:31:48
738
原创 Practice Round APAC test 2017——Problem B. Robot Rock Band
ProblemYou're the manager of Xorbitant, the world's first robot rock band. There will be four positions in the band, and there are N robots auditioning for each position. (No robot is auditioning
2016-10-12 14:20:08
320
原创 Practice Round APAC test 2017——Problem C. Not So Random
ProblemThere is a certain "random number generator" (RNG) which takes one nonnegative integer as input and generates another nonnegative integer as output. But you know that the RNG is really not
2016-10-08 20:52:33
456
原创 Practice Round APAC test 2017——1.Problem A. Lazy Spelling Bee
1.Problem A. Lazy Spelling BeeProblemIn the Lazy Spelling Bee, a contestant is given a target word W to spell. The contestant's answer word A is acceptable if it is the same length as the targ
2016-10-08 15:02:21
575
转载 mac下创建bash_profile步骤
1. 启动终端Terminal2. 进入当前用户的home目录 输入cd ~3. 创建.bash_profile 输入touch .bash_profile4. 编辑.bash_profile文件 输入open .bash_profile 在弹出的页面进行编辑5. 保存文件,关闭.bash_profile6
2016-09-28 14:39:38
3030
1
转载 mac os安装open cv2 for python
转自:http://blog.csdn.net/flyfy1/article/details/8274288看了几篇安装open cv2 for python,感觉都有点麻烦。上面这两个算是比较简单的。我的操作系统是10.7,python 2.7.3。首先就是要安装cmake,这个很简单,brew install cmake。一个命令就搞定。然后下载open cv的
2016-09-28 14:38:38
3725
转载 C++中内存泄漏的几种情况
转载地址:http://blog.csdn.net/lovely20085901/article/details/390500851. 在类的构造函数和析构函数中没有匹配的调用new和delete函数两种情况下会出现这种内存泄露:一是在堆里创建了对象占用了内存,但是没有显示地释放对象占用的内存;二是在类的构造函数中动态的分配了内存,但是在析构函数中没有释放内存或者没有正
2016-09-21 16:13:53
431
原创 Mac OS 环境配置 for caffe
1)安装homebrew 管理工具包,作用相当于 yum 或apt-get$ ruby -e "$(cur1 -fsSL\https://raw.githubusercontent.com/Homebrew/install/master/install)"2) 等待安装成功,然后利用该工具包安装caffe依赖包$ brew install -vd snappy leveldb gfla
2016-09-21 13:37:19
730
原创 385. Mini Parser
/** * // This is the interface that allows for creating nested lists. * // You should not implement it, or speculate about its implementation * class NestedInteger { * public: * // Construc
2016-09-20 20:59:59
206
原创 383. Ransom Note
class Solution {public: bool canConstruct(string ransomNote, string magazine) { int alp[256]={0}; for(int i=0;magazine[i]!='\0';i++) alp[magazine[i]]++; for(in
2016-09-20 20:56:31
216
原创 336. Palindrome Pairs
class Solution {public: bool isPalin(string tmp) { int n=tmp.size(); int i=0,j=n-1; while(i<j) { if(tmp[i]!=tmp[j]) return false;
2016-09-20 20:53:11
248
原创 214. Shortest Palindrome
manacher 算法,寻找s[0..k]为回文串的最长回文串class Solution {public: string shortestPalindrome(string s) { string tmp="$#"; int n=s.size(); int i; for(i=0;i<n;i++) {
2016-09-20 13:13:02
312
原创 227. Basic Calculator II
将数据和符号分别压栈class Solution {public: int calculate(string s) { stack op; stack num; int n=s.size(); int i,j; for(i=0;i<n;i++) { if(s[i]>
2016-09-20 13:08:33
210
原创 273. Integer to English Words
string T[10]={"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};string H[10]={"","Ten","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"};string K[10]={"Ten"
2016-09-20 11:06:46
198
原创 345. Reverse Vowels of a String
class Solution {public: bool isV(char c) { return c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='A'||c=='E'||c=='I'||c=='O'||c=='U'; } string reverseVowels(string s) { in
2016-09-20 11:05:18
201
原创 344. Reverse String
class Solution {public: string reverseString(string s) { int n=s.size(); int i=0,j=n-1; while(i<j) { swap(s[i],s[j]); i++; j--;
2016-09-20 11:04:44
203
原创 165. Compare Version Numbers
可能字符串中没有‘.',或者有多个‘.',所以用递归的方法更加好class Solution {public: int compareVersion(string version1, string version2) { if(version1 == version2) return 0; int po
2016-09-20 11:01:33
236
转载 Microsoft.VisualStudio.Dialogs.DialogInitializationException 问题解决
两种方法:(1)在安装的VS的命令提示符状态下输入“devenv /resetuserdata”,然后回车;(2)删除“%LOCALAPPDATA%\Microsoft\VisualStudio\11.0\ComponentModelCache”路径下的文件,然后重新启动VS.LOCALAPPDATA这个应该是一个环境变量,具体路径查看环境变量里应该可以看到;
2016-09-16 03:04:18
2117
原创 126. Word Ladder II
BFS+DFSclass Solution {public: map> buildTree( string beginWord, string endWord,
2016-09-15 15:34:22
457
原创 115. Distinct Subsequences
dpint dp[2][100000];class Solution {public: int numDistinct(string s, string t) { int n=s.size(),m=t.size(); int i,j; memset(dp,0,sizeof(dp)); if(m>n)
2016-09-15 15:09:37
191
原创 97. Interleaving String
动态规划bool dp[2][1000][1000];class Solution {public: bool isInterleave(string s1, string s2, string s3) { int n=s1.size(),m=s2.size(),l=s3.size(); int i,j,k; if(n+m!=l)
2016-09-15 13:19:01
213
原创 91. Decode Ways
没有前导0的情况,如果有连续两个0,则没有组合int dp[100000];class Solution {public: int numDecodings(string s) { int n=s.size(); if(n==0||s[0]=='0') return 0; dp[1]=1; dp
2016-09-15 12:47:21
318
原创 87. Scramble String
字符串分解成两颗子树,子树的长度任意,所有可以用递归class Solution {public: bool isScramble(string s1, string s2) { int n=s1.size(); int m=s2.size(); int i; if(n!=m) retu
2016-09-15 11:42:26
309
原创 93. Restore IP Addresses
递归class Solution {public: void valid(string s,unordered_set& adds,string add,int cnt,int len) { if(cnt>4) return; if(cnt==4) { if(s!="")
2016-09-15 10:38:51
196
原创 125. Valid Palindrome
双指针class Solution {public: bool isPalindrome(string s) { int n=s.size(); if(n==0) return true; int i=0,j=n-1; while(i<j) { while(
2016-09-15 10:33:32
177
原创 151. Reverse Words in a String
方法1:原地翻转,再单词翻转class Solution {public: void reverseWords(string &s) { vector str; int n=s.size(); int i=0,j=n-1; while(i<j) { swap(s[i],s[j]);
2016-09-15 09:44:42
253
转载 C++中placement new操作符(经典)
析构函数能显式调用,构造函数只能初始化时调用placement new是重载operator new的一个标准、全局的版本,它不能被自定义的版本代替(不像普通的operator new和operator delete能够被替换成用户自定义的版本)。它的原型如下:void *operator new( size_t, void *p ) throw() { return p; }
2016-09-14 21:15:12
241
原创 68. Text Justification
1.最后一行的处理与前面不一样2.空格需要均匀分布class Solution {public: vector fullJustify(vector& words, int maxWidth) { int n=words.size(); vector ans; int i,j; int cur=0;
2016-09-14 11:50:34
217
原创 76. Minimum Window Substring
使用双指针class Solution {public: string minWindow(string s, string t) { int m=t.size(); int n=s.size(); int i,j; unordered_map mp; for(i=0;i<m;i++)
2016-09-14 09:57:24
223
原创 44. Wildcard Matching
动态规划bool dp[100000];bool rp[100000];class Solution {public: bool isMatch(string s, string p) { int m=p.size(),n=s.size(); int i,j; memset(dp, 0, sizeof(dp)); m
2016-09-13 23:04:18
227
原创 72. Edit Distance
动态规划class Solution {public: int minDistance(string word1, string word2) { int dp[1000][1000]; int m=word1.size(); int n=word2.size(); int i,j; memset(dp,
2016-09-13 22:40:23
265
原创 65. Valid Number
当科学计数法时必须前面后面都有数字,且可以带正负号,前面的digit 可以是小数{digit}e{digit}example:2e10-2e-32.3e14.e2.2e81-.2e91小数的表示1.01..1-.1+.8class Solution {public: bool isdig(string s)
2016-09-13 21:14:18
227
原创 71. Simplify Path
class Solution {public: string simplifyPath(string path) { int n=path.size(); vector paths; int i,j; for(i=0;i<n;i++) { string tmp="";
2016-09-13 21:04:39
181
原创 49. Group Anagrams
class Solution {public: vector> groupAnagrams(vector& strs) { map mp; vector> ans; int n=strs.size(); int i,j; for(i=0;i<n;i++) { int t
2016-09-13 21:03:18
170
原创 58. Length of Last Word
class Solution {public: int lengthOfLastWord(string s) { int n=s.size(); int i=n-1,j; while(i>=0&&s[i]==' ') { i--; } j=i; whil
2016-09-13 21:00:03
144
原创 67. Add Binary
class Solution {public: string addBinary(string a, string b) { string ans="",res=""; int n=a.size(); int m=b.size(); if(!n||!m) return ans;
2016-09-13 20:56:02
182
原创 43. Multiply Strings
class Solution {public: string multiply(string num1, string num2) { int n=num1.size(); int m=num2.size(); string ans=""; if(!n||!m) return ans;
2016-09-13 20:52:36
158
原创 30. Substring with Concatenation of All Words
方法1:使用unordered_mapclass Solution {public: bool valid(string s,int sta,vector& words,unordered_map& mp,vector& vt,int m) { int n=words[0].size(); vector num(vt.begin(),vt
2016-09-12 17:07:41
176
原创 32. Longest Valid Parentheses
方法1:使用栈struct P{ int s,e; P(int l,int r):s(l),e(r){}};class Solution {public: int longestValidParentheses(string s) { stack st; stack vs; stack ans;
2016-09-12 15:28:57
161
原创 28. Implement strStr()
方法1:直接匹配,复杂度O(m*n)class Solution {public: int strStr(string haystack, string needle) { int n=haystack.size(); int m=needle.size(); if(n<m) return -1;
2016-09-11 20:13:24
160
Cracking the coding interview 5th
2016-10-12
算法谜题.pdf
2016-10-12
十五个经典算法研究与总结
2016-10-12
编程之魂 与27位编程语言创始人对话
2016-10-12
圣殿祭司的ASP NET 2 0开发详解 使用C#
2014-06-08
Programming ASP.NET中文版(第3版)
2014-06-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人