
LeetCode
文章平均质量分 70
Hacker_vision
一件事,你可以不去做,要做,就要全力以赴,做到最完美。
展开
-
LeetCode330. Patching Array【贪心】
题意 告诉你几个元素组成的数组nums[ ]和表示范围n,问最少向数组中添加多少元素使得从nums[ ]中若干元素之和能够覆盖[1..n]思路 cur表示当前能表示的范围为[1..cur],扫描nums[ ],贪心原则如下: 若nums[i],把nums[i]添加进来,表示范围更新[1..cur+nums[i]]; 若nums[i]>2*原创 2016-01-29 23:24:27 · 1593 阅读 · 0 评论 -
LeetCode11. Container With Most Water(思维题:选择左右边使得容器所盛水最多)
这道题,我独立想了好久!!!!一道很好的思维题!!!!!!!!思路1是自己的求解方法O(nlogn),思路2是网上最优的解法O(n),暴利O(n^2)肯定超时!题目链接:https://leetcode.com/problems/container-with-most-water/Given n non-negative integers a1, a2, .原创 2016-11-30 15:31:13 · 887 阅读 · 0 评论 -
LeetCode14. Longest Common Prefix(字典树:最长公共前缀)
题目链接:https://leetcode.com/problems/longest-common-prefix/Write a function to find the longest common prefix string amongst an array of strings.(最长公共前缀)解题思路:字典树。以任一串去查找,找到最长的且匹配数为n的即可,水题。原创 2016-12-02 11:41:21 · 1619 阅读 · 0 评论 -
Leetcode1.Two Sum+LeetCode15.3Sum+LeetCode18. 4Sum【K-Sum问题】
题目链接:https://leetcode.com/problems/two-sum/ (2-sum)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 inpu原创 2016-12-02 20:14:45 · 670 阅读 · 0 评论 -
LeetCode2. Add Two Numbers(链表加法)
题目链接:https://leetcode.com/problems/add-two-numbers/You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a si原创 2016-11-25 11:00:17 · 821 阅读 · 0 评论 -
LeetCode3. Longest Substring Without Repeating Characters(最长不重复子串)
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/Given a string, find the length of the longest substring without repeating characters.Examples:Given原创 2016-11-25 20:01:50 · 461 阅读 · 0 评论 -
LeetCode4. Median of Two Sorted Arrays(寻找第k小数:分治O(log(n+m)))
题目链接:https://leetcode.com/problems/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原创 2016-11-26 17:02:05 · 702 阅读 · 0 评论 -
LeetCode5. Longest Palindromic Substring(最长回文子串:Manacher算法)
题目链接:https://leetcode.com/problems/longest-palindromic-substring/Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Exampl原创 2016-11-27 11:43:31 · 548 阅读 · 1 评论