- 博客(17)
- 收藏
- 关注
原创 [leetcode]Search for a Range
34. Search for a RangeGiven an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(
2017-05-31 11:19:20 317
原创 [leetcode]Longest Valid Parentheses
32. Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parenthese
2017-05-28 11:02:07 361
原创 [leetcode]排列类问题
31. Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the
2017-05-26 20:45:38 345
原创 [leetcode]Implement strStr()
28. Implement strStr()Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.字符串模式匹配: 1.brute force:int strStr(string haystack, st
2017-05-26 17:26:10 343
原创 [leetcode]单链表类题目总结(应用双指针)
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */24. Swap Nodes in Pairs Given a linked lis
2017-05-25 21:49:05 731
原创 [leetcode]Longest Common Prefix
14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.我的代码:string longestCommonPrefix(vector<string>& strs){ string lcp; if (strs.emp
2017-05-25 15:14:39 330
原创 [leetcode]Container With Most Water
11. Container With Most Water Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (
2017-05-25 12:17:22 273
原创 [leetcode]Median of Two Sorted Arrays
4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n
2017-05-19 17:36:49 495
原创 Leetcode string题目中的双指针模板
leetcode中有不少求最长或者最短满足特定条件子串的长度,这些题目都有共性:使用双指针,且使用哈希表记录字符出现的次数。有高人总结的模板,配合一下总结的该类问题食用更加! Template:int findSubstring(string s) { vector<int> map(128, 0); int counter = 0; // check wh
2017-05-19 16:30:09 1065
原创 [leetcode]求和类问题
Two sum i Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use
2017-05-19 11:22:17 366
原创 leetcode刷题阶段总结
从过年到现在一直在刷题,从第一开始一天十题,到现在每天五题,还是能明显感觉自己写代码的思路比以前清晰不少,对基本的数据结构与算法复习了一遍,学习了一些以前不知道的理论,比如Sprague-grundy。刚开始的时候自己的写的程序总是时间复杂度很高,而且很不优美,一直很羡慕像StefanPochmann这样的大神,写出的代码简洁明了。我一直是按照leetcode划分的算法模块开刷的,然后无论题目是ea
2017-05-19 10:54:10 1107
原创 [leetcode]Super Washing Machines
517. Super Washing Machines You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty. For each move, you could choose any m (1 ≤ m ≤ n) washing machin
2017-05-18 12:14:46 711
原创 [leetcode] predict the winner
predict the winnerGiven an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time
2017-05-17 21:47:34 351
原创 [leetcode]ones and zeros
Ones and Zeroes Add to List. In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.For now, suppose you are a dominator of m 0s and n 1s
2017-05-17 19:22:06 567
原创 [leetcode]Unique Substrings in Wraparound String
Unique Substrings in Wraparound String Consider the string s to be the infinite wraparound string of “abcdefghijklmnopqrstuvwxyz”, so s will look like this: “…zabcdefghijklmnopqrstuvwxyzabcdefghijklmn
2017-05-17 16:55:03 520
原创 [Leetcode]Count The Repetitions
Count The Repetitions Define S = [s,n] as the string S which consists of n connected strings s. For example, [“abc”, 3] =”abcabcabc”. On the other hand, we define that string s1 can be obtained from
2017-05-17 15:19:53 1690
原创 [leetcode flip game ii]sprague–grundy theorem
I learn this theorem from the discuss post of problem flip game ii The discuss post is here: Theory matters - from Backtracking(128ms) to DP (0ms)SG theorem is used to determine how to force a win for
2017-05-16 13:00:29 721
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人