摘要:
http://oj.leetcode.com/problems/two-sum/求是否存在两个数的和为target,暴力法,两层循环#include #include #include using namespace std;class Solution {public: vector twoSum(vector &numbers, int target) { // Note: The Solution object is instantiated only once and is reused by each test case. //sort(number...
阅读全文
posted @ 2013-10-26 11:46
qingcheng奕
阅读(184)
推荐(0)
摘要:
http://oj.leetcode.com/problems/longest-valid-parentheses/最大括号匹配长度,括号是可以嵌套的#include #include #include #include using namespace std;class Solution {public: int longestValidParentheses(string s) { const int s_len = s.size(); stack indexstack; vector flagvector; int templ...
阅读全文
posted @ 2013-10-26 10:51
qingcheng奕
阅读(134)
推荐(0)
摘要:
http://oj.leetcode.com/problems/longest-valid-parentheses/最大括号匹配长度,括号是可以嵌套的。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 class Solution { 7 public: 8 int longestValidParentheses(string s) { 9 const int s_len = s.size();10 11 stack indexstack;12 ...
阅读全文
posted @ 2013-10-26 10:49
qingcheng奕
阅读(129)
推荐(0)