- 博客(5)
- 资源 (18)
- 收藏
- 关注
原创 【leetcode】3Sum, 3Sum Closest
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c
2016-06-03 20:42:31 367
原创 【leetcode】Implement strStr()
曾经被百度面试官虐的时候碰到过这题。注意:字符串以'\0'结束,NULL和'\0'不等价。暴力解决:外循环:遍历haystack;内循环:遍历needle,若字符不匹配则跳出,当遍历到needle结束时,返回当前i,若遍历到haystack结束,则不存在匹配子串,返回-1。int strStr(char* haystack, char* needle){ if
2016-06-03 15:00:08 332
原创 【leetcode】Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.思路:将链表尾部和头部连起来,顺便算出链表长度len计算k
2016-06-02 21:36:50 360
原创 【leetcode】Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "
2016-06-02 21:29:45 353
原创 【leetcode】Minimum Window Substring
class Solution {public: string minWindow(string s, string t) { vector dict(128, 0); for (auto c : t) ++dict[c]; int counter = t.size(); int begin =
2016-06-02 13:49:47 455
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人