上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页
摘要: Given n pairs of parentheses, write a function to generate all combinations of well formed parentheses. For example, given n = 3, a solution set is: [ 阅读全文
posted @ 2017-03-20 22:43 aiterator 阅读(79) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters '(' and ')', find the length of the longest valid (well formed) parentheses substring. For "(()", the lo 阅读全文
posted @ 2017-03-20 15:19 aiterator 阅读(108) 评论(0) 推荐(0) 编辑
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2017-03-19 20:20 aiterator 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Implement regular expression matching with support for '.' and ' '. '.' Matches any single character. ' ' Matches zero or more of the preceding elemen 阅读全文
posted @ 2017-03-18 10:12 aiterator 阅读(88) 评论(0) 推荐(0) 编辑
摘要: You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a conca 阅读全文
posted @ 2017-03-17 16:11 aiterator 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 题目链接: + 题目大意: + 有一些木棍,木棍两端有不同的颜色; + 两个木棍能够排列到一块,当且仅当两个木棍相邻端点颜色一样; + 问这些木棍能否全部链接到一块; 解题思路: + 首先,可以将每一个颜色,看做是一个点; + 木棍就可以看做为两个颜色之间的一条边; + 然后就可以组成一个图; + 阅读全文
posted @ 2017-03-17 13:48 aiterator 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题目链接: + 题目大意: + 一个NxN矩阵,有一些障碍在矩阵中; + 消除障碍,一次可以消除一行或者一列; + 问最小次数 解题思路: + 可以将每一行,每一列看做一个端点; + 障碍看做两个端点之间的边, 那么NxN矩阵就转化为了一个无向图。 + 最后只求最小点覆盖,即为答案 + 最小点覆盖 阅读全文
posted @ 2017-03-17 08:50 aiterator 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to 阅读全文
posted @ 2017-03-16 16:27 aiterator 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 简单dp 假设dp[i]为前i个字符能够最小去除dp[i]个元素,剩下的可以由字符串组成。所以可知 dp[i] = min(dp[i], dp[i j] + i j len); 其中len为[i j,i]区间, 存在的字符串的长度。 但是由于,对于每一个i,都要向前面找j。 这样就会很麻烦。 那么只 阅读全文
posted @ 2017-03-14 19:25 aiterator 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 刚看到这个题目, 还有为几个if,else就可以了, 然后就开始敲了, 后来发现并没有那么简单。 参考题解: C++ include using namespace std; int solve(long long a, long long b, long long k) { if(a == 0) 阅读全文
posted @ 2017-03-12 21:13 aiterator 阅读(307) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页