算法
文章平均质量分 64
一个普通的本科生
这个作者很懒,什么都没留下…
展开
-
(算法分析Week19)Longest Substring Without Repeating Characters 最长无重复子串 [Medium]
3.Longest Substring Without Repeating Characters 最长无重复子串 [Medium][题目来源https://leetcode.com/problems/longest-substring-without-repeating-characters/description/)DescriptionGiven a string, find th原创 2018-01-20 21:10:35 · 163 阅读 · 0 评论 -
(算法分析Week12)Count Numbers with Unique Digits[Medium]
357. Count Numbers with Unique Digits题目来源DescriptionGiven a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example: Given n = 2, return 91. (The answer should be th原创 2017-11-26 14:05:50 · 149 阅读 · 0 评论 -
(算法分析Week13)Combination Sum IV[Medium]
506. 377. Combination Sum IV[Medium]题目来源DescriptionGiven an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.原创 2017-12-01 23:43:33 · 164 阅读 · 0 评论 -
(算法分析Week13)Is Subsequence[Medium]
506. Relative Ranks[Easy]题目来源DescriptionGiven a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a原创 2017-12-01 23:10:06 · 160 阅读 · 0 评论 -
(算法分析Week13)Relative Ranks[Easy]
506. Relative Ranks[Easy]题目来源DescriptionGiven scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: “Gold Medal”, “Silver Medal”原创 2017-12-01 22:25:14 · 154 阅读 · 0 评论 -
(算法分析Week14)Split Array Largest Sum[Hard]
410. Split Array Largest Sum[Hard]题目来源DescriptionGiven an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorit原创 2017-12-09 20:36:53 · 189 阅读 · 0 评论 -
(算法分析Week14)Arithmetic Slices[Medium]
413.Arithmetic Slices[Medium]题目来源DescriptionA sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.Fo原创 2017-12-09 20:09:57 · 168 阅读 · 0 评论 -
(算法分析Week14)House Robber[Easy]
198. House Robber[Easy]题目来源DescriptionYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbin原创 2017-12-09 19:46:12 · 154 阅读 · 0 评论 -
(算法分析Week5)Palindrome Number[Easy]
9.Palindrome NumberDescriptionDetermine whether an integer is a palindrome. Do this without extra space. 判断一个数是不是回文。原创 2017-10-04 14:31:10 · 241 阅读 · 0 评论 -
(算法分析Week9)Wildcard Matching[Hard]
44.Wildcard Matching[Hard]外卡匹配,Leetcode原创 2017-11-05 13:45:09 · 214 阅读 · 0 评论 -
(算法分析Week9)Regular Expression Matching[Hard]
10.Regular Expression Matching[Hard]正规表达式匹配,Leetcode原创 2017-11-05 13:34:12 · 267 阅读 · 0 评论 -
(算法分析Week12)Unique Paths[Medium]
62.Unique Paths[Medium]题目来源DescriptionA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time.原创 2017-11-26 14:14:33 · 159 阅读 · 0 评论 -
(算法分析Week12)Unique Paths II[Medium]
63.Unique Paths II[Medium]Unique Paths升级版原创 2017-11-26 14:31:25 · 240 阅读 · 0 评论 -
(算法分析Week18)Subsets[Medium]
78. Subsets[Medium]题目来源DescriptionGiven a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example,原创 2018-01-05 19:15:35 · 158 阅读 · 0 评论 -
(算法分析Week18)Gray Code[Medium]
89. Gray Code[Medium][题目来源https://leetcode.com/problems/gray-code/description/)DescriptionThe gray code is a binary numeral system where two successive values differ in only one bit.Given a no原创 2018-01-05 19:52:55 · 189 阅读 · 0 评论 -
(算法分析Week18)1-bit and 2-bit Characters[Easy]
717. 1-bit and 2-bit Characters[Easy]题目来源DescriptionWe have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 o原创 2018-01-05 19:23:20 · 174 阅读 · 0 评论 -
(算法分析Week17)Chapter8作业
8.3 STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if such an assignm原创 2017-12-28 13:47:50 · 332 阅读 · 0 评论 -
(算法分析Week15)Best Time to Buy and Sell Stock with Cooldown[Medium]
309. Best Time to Buy and Sell Stock with Cooldown[Medium]题目来源DescriptionSay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum p原创 2017-12-16 12:51:54 · 261 阅读 · 0 评论 -
(算法分析Week15)2 Keys Keyboard[Medium]
650.2 Keys Keyboar[Medium]题目来源DescriptionInitially on a notepad only one character ‘A’ is present. You can perform two operations on this notepad for each step:1.Copy All: You can copy all the characte原创 2017-12-16 12:37:04 · 189 阅读 · 0 评论 -
(算法分析Week15)01Matrix[Medium]
542. 01 Matrix[Medium]题目来源DescriptionGiven a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1. Example 1: Input:0 0 00 1 00原创 2017-12-16 12:19:04 · 257 阅读 · 0 评论 -
(算法分析Week16)132 Pattern[Medium]
456. 132 Pattern[Medium]题目来源DescriptionGiven a sequence of n integers a1, a2, …, an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a lis原创 2017-12-23 13:20:48 · 241 阅读 · 0 评论 -
(算法分析Week16)Accounts Merge[Medium]
721. Accounts Merge[Medium]题目来源DescriptionGiven a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails原创 2017-12-23 13:08:29 · 958 阅读 · 0 评论 -
(算法分析Week16)Remove Nth Node From End of List[Medium]
309. 19. Remove Nth Node From End of List[Medium]题目来源DescriptionGiven a linked list, remove the nth node from the end of list and return its head.Example: Given linked list: 1->2->3->4->5, and n = 2.原创 2017-12-23 11:32:12 · 163 阅读 · 0 评论 -
(算法分析Week11)Swap Nodes in Pairs[Medium]
24.Swap Nodes in Pairs[Medium]题目来源DescriptionGiven a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorit原创 2017-11-18 21:58:10 · 343 阅读 · 0 评论 -
(算法分析Week11)Generate Parentheses[Medium]
22.Generate Parentheses题目来源DescriptionGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))",原创 2017-11-18 20:32:19 · 169 阅读 · 0 评论 -
(算法分析Week6)Container With Most Water[Medium]
11.Container With Most Water题目来源DescriptionGiven 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 li原创 2017-10-15 13:57:42 · 160 阅读 · 0 评论 -
(算法分析Week1)Different Ways to Add Parentheses[Medium]
241. Different Ways to Add Parentheses[Medium]DescriptionGiven a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and op原创 2017-09-10 19:13:18 · 273 阅读 · 0 评论 -
(算法分析Week2)Two Sum[Easy]
1. Two Sum[Easy]DescriptionGiven 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 y原创 2017-09-15 20:48:11 · 274 阅读 · 0 评论 -
(算法分析Week2)3Sum[Medium]
241. Different Ways to Add Parentheses[Medium]DescriptionGiven 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 s原创 2017-09-15 21:55:19 · 219 阅读 · 0 评论 -
(算法分析Week2)Roman to Integer[Easy]
水题…… 只要知道罗马数字符号对应的整数就好了。原创 2017-09-16 13:58:06 · 200 阅读 · 0 评论 -
(算法分析Week3)Pow(x,n)[Medium]
50. Pow(x, n)DescriptionImplement pow(x, n). 就是实现幂函数。Solution最直观的想法是递归,每次x*pow(x, n-1),觉得会超时,没写。 然后想着循环,试了一下,超时。 考虑到n个x相乘式子的对称关系,每次循环x*=x,可以把复杂度降到O(logn)Complexity analysisO(logn)Codeclass Solution原创 2017-09-23 22:06:31 · 224 阅读 · 0 评论 -
(算法分析Week3)Reverse Integer[Easy]
7. Reverse IntegerDescriptionReverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321Note: The input is assumed to be a 32-bit signed integer. Your function should r原创 2017-09-23 22:24:38 · 191 阅读 · 0 评论 -
(算法分析Week3)Merge Two Sorted Lists[Easy]
21. Merge Two Sorted ListsDescriptionMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Solution考察对链表的操作,画个图一目了原创 2017-09-23 22:47:47 · 165 阅读 · 0 评论 -
(算法分析Week4)Median of Two Sorted Arrays[Hard]
Topk问题,特殊化中位数。原创 2017-09-30 12:41:52 · 167 阅读 · 0 评论 -
(算法分析Week4)Count and Say[Easy]
38. Count and SayDescriptionThe count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as “one 1”原创 2017-09-30 13:02:54 · 241 阅读 · 0 评论 -
(算法分析Week5)Add Two Numbers[Medium]
2. Add Two NumbersDescriptionYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add原创 2017-10-04 14:37:36 · 196 阅读 · 0 评论 -
(算法分析Week1)Majority Element[Easy]
169. Majority Element[Easy]DescriptionGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is no原创 2017-09-09 21:40:23 · 266 阅读 · 0 评论 -
(算法分析Week1)Maximum Subarray[Easy]
53. Maximum Subarray[Easy]DescriptionFind the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the原创 2017-09-09 12:06:17 · 215 阅读 · 0 评论 -
(算法分析Week6)Longest Palindromic Substring[Medium]
5. Longest Palindromic Substring题目来源DescriptionGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000 Example:Input: "babad"Output: "bab"Not原创 2017-10-15 12:17:24 · 163 阅读 · 0 评论 -
(算法分析Week10)Letter Combinations of a Phone Number[Medium]
17. Letter Combinations of a Phone Number[Medium]题目来源DescriptionGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on原创 2017-11-09 13:59:26 · 241 阅读 · 0 评论