- 博客(18)
- 资源 (5)
- 收藏
- 关注
原创 【数学】Count Primes
题目:leetcodeCount PrimesDescription:Count the number of prime numbers less than a non-negative number, n分析:求出比n小的素数的个数,这个问题可以用排除法做,参考http://www.cnblogs.com/grandyang/p/4462810.html
2015-04-28 19:13:04 673
原创 临时变量与复制构造函数(二)
为了直观观察,以下代码中复制构造函数会把成员变量num+1class B{ int num;public: B():num(0){ cout << "默认构造函数" << " num= "<< num <<endl; } B(int n) :num(n){ cout << "带参构造函数" << " num= " << num << endl; } B(const
2015-04-23 10:30:43 737
原创 临时变量与复制构造函数
class B{public: B(){ cout << "构造函数" << endl; } B(const B &b) { cout << "复制构造函数" << endl; } ~B() { cout << "析构函数" << endl; }};B play(B b){ return b;}main函数输入如下代码:{ B b
2015-04-23 09:23:59 998
原创 【数学】约瑟夫环问题中,最后剩下的人是第几个人
题目:约瑟夫环问题中,最后剩下的人是第几个人。如一共4个人,数到2的人出列,最后剩下的那个人是第1个人,返回1.int Josephus(int n, int k){ if (n<=0 || k<1) throw exception(); if (n==1) return 1;//人为规定,n为1时返回1 int res=k%2;//只有两个人时,返回的人的下标(从零开
2015-04-22 10:45:31 2856
转载 【位操作】Bitwise AND of Numbers Range
题目:leetcodeBitwise AND of Numbers RangeGiven a range [m, n] where 0 For example, given the range [5, 7], you should return 4.参考:http://www.cnblogs.com/lailailai/p/4430972.html分析:对[
2015-04-16 11:06:48 346
原创 【回溯法】Permutations II
题目:leetcodePermutations II Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique perm
2015-04-15 19:38:12 569
原创 【回溯法】Sudoku Solver
题目:leetcodeSudoku Solver Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be on
2015-04-15 18:43:46 852
转载 【字符串匹配】Implement strStr()
题目:leetcodeImplement strStr() Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.参考:http://www.tuicool.com/arti
2015-04-15 11:09:36 480
原创 Text Justification
题目:leetcodeText JustificationGiven an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack
2015-04-14 18:30:38 456
原创 【哈希、动态规划】Edit Distance
题目:leetcodeEdit Distance Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the fo
2015-04-13 18:23:07 470
原创 【栈、动态规划】Longest Valid Parentheses
题目:leetcodeLongest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the l
2015-04-13 15:30:04 614
原创 【动态规划+滚动数组】Interleaving String
题目:leetcodeInterleaving String Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcb
2015-04-10 18:05:22 666
原创 【广度优先遍历】Number of Islands
题目:leetcodeNumber of Islands Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent l
2015-04-10 10:19:56 582
转载 【广度优先遍历】Word Ladder II
题目:leetcodeWord Ladder II Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be change
2015-04-07 10:21:07 588
原创 【哈希表】Longest Consecutive Sequence
题目:leetcodeLongest Consecutive Sequence Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2]
2015-04-06 16:00:27 565
原创 【动态规划】Dungeon Game
题目:leetcodeDungeon Game The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid.
2015-04-05 22:43:15 553
转载 【动态规划】Best Time to Buy and Sell Stock IV
题目:leetcodeBest Time to Buy and Sell Stock IV Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit.
2015-04-03 14:50:35 535
原创 【贪婪算法、动态规划】Jump Game II
题目:leetcodeJump Game II Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump
2015-04-01 15:33:17 890
VC++程序: 将字符串转换成公式并计算结果
2014-10-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人