码迷,mamicode.com
首页 >  
搜索关键字:r语言中的 vector    ( 11651个结果
leetcode 2SUM
structvp{intvalue;intplace;};boolcomp(conststructvpa,conststructvpb){returna.valuetwoSum(vector&numbers,inttarget){vectorv;for(inti=0;itarget){break.....
分类:其他好文   时间:2014-09-28 14:27:32    阅读次数:210
leetcode Evaluate Reverse Polish Notation
#include#include#include#include#include#include#includeusingnamespacestd;intevalRPN(vector&tokens){stackvalue;inti=0;for(i=0;is;s.push_back("4");s.pu...
分类:其他好文   时间:2014-09-28 00:52:20    阅读次数:209
Interleaving String [leetcode] DP
dp[k1][k2]:s1[0...k1-1]和s2[0...k2-1]能否合成s3[0...k1 + k2 - 1] bool isInterleave(string s1, string s2, string s3) { if (s3.size() != s1.size() + s2.size()) return false; vector> dp(s...
分类:其他好文   时间:2014-09-28 00:41:51    阅读次数:161
Binary Tree Inorder Traversal [leetcode] 非递归的三种解法
第一种方法是Morris Traversal 是O(n)时间复杂度,且不需要额外空间的方法。缺点是需要修改树。 通过将叶子节点的right指向其中序后继。 代码如下 vector inorderTraversal(TreeNode *root) { vector res; TreeNode * cur = root; TreeNode...
分类:其他好文   时间:2014-09-27 22:46:50    阅读次数:195
leetcode-Best Time to Buy and Sell Stock
一定要判断好边界条件,edge case很关键。 1 #include 2 #include 3 using namespace std; 4 5 class Solution { 6 public: 7 int maxProfit(vector &prices) { 8 ...
分类:其他好文   时间:2014-09-27 19:02:20    阅读次数:202
leetcode - Gas Station
//假设sum为总的耗油量,max为起始点a到终点b的耗油量,如果,当到达b的时候, //max < 0,那么,出发点肯定不能从a开始,这个时候将max = 0,然后,pos = i+1,选择pos为起始点,然后继续遍历。 //如果,最后的sum = 0,则返回pos. class Solution { public: int canCompleteCircuit(std::vector ...
分类:其他好文   时间:2014-09-27 15:36:29    阅读次数:198
STL容器介绍(转)
STL的容器可以分为以下几个大类:一:序列容器, 有vector, list, deque, string.二 : 关联容器, 有set, multiset, map, mulmap, hash_set, hash_map, hash_multiset, hash_multimap三: 其他的杂项:...
分类:其他好文   时间:2014-09-27 12:46:59    阅读次数:186
算法题-数组的最长非递减子序列
1 int binSearch(const vector &tail, int len, int key)// 2 { 3 int left = 0, right = len - 1; 4 int mid; 5 6 while(left > 1); 9 i...
分类:其他好文   时间:2014-09-27 04:32:09    阅读次数:230
Restore IP Addresses [leetcode]
这题乍一看有点像Decode Ways ,实际上是一个深搜+剪枝的题目 也可以通过三个for循环寻找可行的‘.’的位置 递归方法如下: vector restoreIpAddresses(string s) { vector res; restore(s, 0, 0, res, ""); return res; } ...
分类:其他好文   时间:2014-09-27 02:11:09    阅读次数:199
2-11. 两个有序链表序列的合并(15) (ZJUPAT 用vector实现)
2-11. 两个有序链表序列的合并(15) (ZJUPAT 用vector实现)...
分类:其他好文   时间:2014-09-26 23:47:39    阅读次数:477
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!