
Leetcode Alorithm
文章平均质量分 64
Kelly Fu
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Fizz Buzz(412)
412—Fizz BuzzWrite a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five outp...原创 2018-12-13 11:54:25 · 183 阅读 · 0 评论 -
Task Scheduler(621)
621— Task SchedulerGiven a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original ord...原创 2018-12-27 20:55:13 · 159 阅读 · 0 评论 -
Degree of an Array(697)
697—Degree of an ArrayGiven a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest...原创 2018-12-11 21:55:32 · 115 阅读 · 0 评论 -
Fraction Addition and Subtraction(592)
592—Fraction Addition and SubtractionGiven a string representing an expression of fraction addition and subtraction, you need to return the calculation result in string format. The final result shoul...原创 2018-12-11 21:57:56 · 323 阅读 · 0 评论 -
Longest Substring with At Least K Repeating Characters(395)
395—Longest Substring with At Least K Repeating CharactersFind the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no l...原创 2018-12-18 17:09:49 · 200 阅读 · 0 评论 -
Add Two Numbers(2)
2— Add Two NumbersYou 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 the two n...原创 2018-12-24 14:51:17 · 128 阅读 · 0 评论 -
Climbing Stairs(70) - easy
70— Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n ...原创 2019-01-10 16:23:49 · 249 阅读 · 0 评论 -
Best Time to Buy and Sell Stock(121) - easy
121— Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy ...原创 2019-01-10 20:09:56 · 125 阅读 · 0 评论 -
House Robber(198) - easy
198— House RobberYou 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 robbing each of them is ...原创 2019-01-10 21:48:28 · 169 阅读 · 0 评论 -
Maximum Subarray(53) - easy
53— Maximum SubarrayGiven an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example1:Input: [-2,1,-3,4,-1,2,1,-5,4]...原创 2019-01-11 00:58:33 · 345 阅读 · 0 评论 -
ZigZag Conversion(6) -medium
6 — ZigZag Conversion1. 题目描述2. 思路分析题目:遍历字符串, 确定有几行, 确定每个字符在第几行。 两个转折点:在第0行和第numRows-1行处,要改变方向,也就是curRow变量加一还是减一。3. Python代码:def convert(s: str, numRows: int): rowLength = min(len(s), num...原创 2019-06-20 17:03:13 · 183 阅读 · 0 评论 -
Min Stack(155)
155— Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack....原创 2018-12-26 22:33:26 · 112 阅读 · 0 评论 -
Valid Parentheses(20)
20— Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed ...原创 2018-12-26 21:35:09 · 98 阅读 · 0 评论 -
Random Pick Index(398)
398—Random Pick IndexGiven an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note...原创 2018-12-13 17:05:48 · 174 阅读 · 0 评论 -
Score of Parentheses(856)
856— Score of ParenthesesGiven a balanced parentheses string S, compute the score of the string based on the following rule:“()” has score 1“AB” has score A + B, where A and B are balanced parenth...原创 2018-12-19 21:24:00 · 233 阅读 · 0 评论 -
Letter Case Permutation(784)
784— Letter Case PermutationGiven a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create....原创 2018-12-20 11:48:49 · 167 阅读 · 0 评论 -
Permutations(46)
46— PermutationsGiven a collection of distinct integers, return all possible permutations.Example 1:Input: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]C++代码:class So...原创 2018-12-20 18:02:35 · 221 阅读 · 0 评论 -
Rotate String
Rotate StringWe are given two strings, A and B.A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = ‘abcde’, then it will be ‘bcd...原创 2018-10-07 23:54:42 · 252 阅读 · 0 评论 -
Palindrome Number
Palindrome NumberDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Outp...原创 2018-09-30 21:49:56 · 123 阅读 · 0 评论 -
Reverse Integer
Reverse IntegerGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume w...原创 2018-09-23 22:46:56 · 169 阅读 · 0 评论 -
Two Sum
Two SumGiven 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 ...原创 2018-09-16 00:47:03 · 139 阅读 · 0 评论 -
Valid Triangle Number(511)
511—Valid Triangle NumberGiven an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths o...原创 2018-12-10 12:11:26 · 162 阅读 · 0 评论 -
Decode String(394)
394— Decode StringGiven an encoded string, return it’s decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. ...原创 2018-12-26 21:00:18 · 215 阅读 · 0 评论 -
Longest Substring Without Repeating Characters(3) -medium
3 — Longest Substring Without Repeating Characters1. 题目描述2. 思路分析题目:方法一:暴力枚举法(这种方法提交会超时Time Limit Exceeded)列举出所有的子序列,判断每一个子序列是否重复, 记录最大子序列。方法二:滑动窗口遍历字符串, 如果重复了,则左边的窗口往右滑动一个位置, 继续判断, 如果没...原创 2019-06-21 21:33:32 · 147 阅读 · 0 评论