
LeetCode
文章平均质量分 61
u010105243
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Feb_0219_Leetcode_32_Longest Valid Parentheses
DescriptionGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()"原创 2017-02-20 21:42:48 · 281 阅读 · 0 评论 -
20170401-leetcode-435-Non-overlapping Intervals
1.DescriptionGiven a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. Given a collection of intervals, merge all ov原创 2017-04-04 15:40:58 · 324 阅读 · 0 评论 -
20170529-leetcode-582-Kill process
1.DescriptionGiven n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but may have one or more children processes. This原创 2017-05-29 21:31:45 · 1165 阅读 · 0 评论 -
20170630-leetcode-225 Implement Stack using Queues
1.DescriptionImplement the following operations of a stack using queues. - push(x) – Push element x onto stack. - pop() – Removes the element on top of the stack. - top() – Get the top element. - e原创 2017-05-30 10:21:12 · 400 阅读 · 0 评论 -
201705031-leetcode-155-Min Stack
1.DescriptionDesign 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.top原创 2017-05-31 15:30:57 · 307 阅读 · 0 评论 -
20170604-leetcode-460-LFU Cache
1.DescriptionDesign and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of t原创 2017-06-04 23:34:14 · 494 阅读 · 0 评论 -
20170615-leetcode-409. Longest Palindrome
1.DescriptionGiven a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is原创 2017-06-15 23:34:04 · 252 阅读 · 0 评论 -
20170605-leetcode-532-K-diff Pairs in an Array
1.DescriptionGiven an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are bot原创 2017-06-05 23:17:30 · 511 阅读 · 0 评论 -
20170606-leetcode-581-Shortest Unsorted Continuous Subarray
1.DescriptionGiven an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You nee原创 2017-06-06 11:24:09 · 592 阅读 · 0 评论 -
20170602-leetcode-211-Add and Search Word - Data structure design
1.DescriptionDesign a data structure that supports the following two operations:void addWord(word) bool search(word)search(word) can search a literal word or a regular expression string containing onl原创 2017-06-02 22:32:30 · 403 阅读 · 0 评论 -
20170607-leetcode-189-Rotate Array
1.DescriptionRotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note: Try to come up as many solutions as原创 2017-06-07 15:41:22 · 327 阅读 · 0 评论 -
20170603-leetcode-560-Subarray Sum Equals K
1.DescriptionGiven an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1,1,1], k = 2 Output: 2Note:The length原创 2017-06-03 16:16:06 · 358 阅读 · 0 评论 -
20170612-leetcode-575-Distribute Candies
Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these原创 2017-06-12 10:32:53 · 783 阅读 · 0 评论 -
20170611-leetcode-041-First Missing Positive
1.DescriptionGiven an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses co原创 2017-06-12 11:25:03 · 332 阅读 · 0 评论 -
20170613-leetcode-535-Encode and Decode TinyURL
1.Description Note: This is a companion problem to the System Design problem: Design TinyURL.TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-ti原创 2017-06-13 10:36:33 · 973 阅读 · 0 评论 -
20170708-leetcode-258-Add Digits
1.DescriptionGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only原创 2017-07-08 21:45:52 · 312 阅读 · 0 评论 -
【Python代码】给定正整数,在+-*/的情况下,算法实现24点游戏,计算所有的可能
下面回顾一下前两天面试过程中,做的一到笔试题:题目:计算24 点,输入4 个整数,如何计算得到24,输出所有可能的计算方式; 若不能计算得到则输出None。解题思路:由于不考虑顺序, 括号的位置可以认为有两种[(a, b, c)d ] [(a,b),(c,d)],然后递归地遍历所有的情况。里面有两个小点:(1) a+b和b+a的情况一样,可以去掉一部分的计算(2) 主函数中考虑到浮点计算,...原创 2018-10-17 22:25:12 · 1525 阅读 · 0 评论 -
20170403-leetcode-349/50-Intersection of Two Arrays.py
两个同类型的题:349/350. 349:1、2;350:3,41.DescriptionGiven two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the原创 2017-04-03 10:44:44 · 770 阅读 · 0 评论 -
20170401-leetcode-435-Non-overlapping Intervals
2017年4月1日 17:29:071.DescriptionGiven a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note:You may assume the interv原创 2017-04-02 21:14:42 · 283 阅读 · 0 评论 -
20170323-leetcode-089-Gray Code
1.DescriptionThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequ原创 2017-03-23 23:04:49 · 302 阅读 · 0 评论 -
20170218-leetcode-067:Add Binary
比较简单的一道题,但是感觉代码有些冗余,不过现阶段只能写出这样的代码了,需要注意的是考虑进位的问题,应当把进位放到循环里面:主要的思路是:把字符串变成单个数字放到list中,然后reverse,把两个list补全成等长的,然后从第一个数字相加,添加到另外的一个list,考虑进位,最后再reverse,然后变成int,去掉多余的0,再变成str类型。67.问题表述Given two bina原创 2017-02-18 20:12:13 · 484 阅读 · 0 评论 -
20170301-leetcode-215-Kth Largest Element in an Array
1.DescriptionFind the **k**th largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and k =原创 2017-03-01 23:17:35 · 299 阅读 · 0 评论 -
20170223-leetcode-091-Number of Segments in a String
1.DescriptionA message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the tota原创 2017-02-25 00:07:52 · 241 阅读 · 0 评论 -
20170223-LeetCode_434_Number of Segments in a String
1.DescriptionCount the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain any non-printable char原创 2017-02-23 09:49:11 · 306 阅读 · 0 评论 -
20170225-leetcode-151-Reverse Words in a String
1.DescriptionGiven an input string, reverse the string word by word.For example, Given s = “the sky is blue”, return “blue is sky the”.Update (2015-02-12): For C programmers: Try to solve it in-plac原创 2017-02-25 20:57:34 · 278 阅读 · 0 评论 -
20170308-leetcode-445-Add Two Numbers
1.DescriptionYou are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers原创 2017-03-08 23:44:31 · 415 阅读 · 0 评论 -
2017-0220-leetcode-043 Multiply Strings
DescriptionGiven two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is < 110.Both num1 and num2 contains only di原创 2017-02-20 10:43:42 · 451 阅读 · 0 评论 -
20170221-leetcode-227-Basic-Calculator
1.DescriptionImplement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division原创 2017-02-22 17:01:34 · 243 阅读 · 0 评论 -
20170306-leetcode-202-Happy Number
1.DescriptionWrite an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the原创 2017-03-06 22:17:41 · 344 阅读 · 0 评论 -
20170307-leetcode-263-Ugly Number
1.DescriptionWrite a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugl原创 2017-03-07 11:17:23 · 316 阅读 · 0 评论 -
20170320-leetcode-401-Binary Watch
2017-03-20 20:51:00 星期一1.Descriptionhttps://leetcode.com/problems/binary-watch/#/description A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represe原创 2017-03-20 23:00:57 · 341 阅读 · 0 评论 -
20170311-leetcode-Fractial Trailing Zeroes
1.Fractorial Trailing ZeroesGiven an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. https://leetcode.com/problems/factorial-trail原创 2017-03-11 11:58:29 · 334 阅读 · 0 评论 -
20170328-leetcode-452-Minimum Number of Arrows to Burst Balloons
1.DescriptionThere are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it’s horizonta原创 2017-03-28 11:14:52 · 349 阅读 · 0 评论 -
20170321-leetcode-131-Palindrome partitioning
1.DescriptionGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab", Return[ ["aa","b原创 2017-03-21 18:14:37 · 311 阅读 · 0 评论 -
20170314-leetcode-278-First Bad Version
1.DescriptionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed原创 2017-03-14 10:51:13 · 280 阅读 · 0 评论 -
python实现模糊匹配
题目:模糊匹配, ‘?’代表一个字符, *代表任意多个字符。给一段明确字符比如avdjnd 以及模糊字符比如*dj?dji?ejj,判断二者是否匹配。若能匹配输出”Yes”, 否则输出“No”(为了方便阅读,代码里面输出Ture or False)解题的思路:通过明确终止条件通过递归的方式求解终止的条件:(1) Str为空 以及 pattern为空或者pattern元素只有[*], 输出T...原创 2018-10-17 22:39:30 · 41356 阅读 · 4 评论