- 博客(75)
- 收藏
- 关注
原创 Leetcode-148. Sort List-python
Leetcode-148. Sort List-python问题描述:Sort a linked list in O(n log n) time using constant space complexity.将一个链表排序,限制了时间复杂度和空间复杂度Example:Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Out
2020-07-01 10:37:27 160
原创 Leetcode-139. Word Break(Medium)-python
Leetcode-139. Word Break(Medium)-python问题描述:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.Note:The same word in
2020-06-26 08:57:39 174
原创 Leetcode Surrounded Regions(Medium)-python
Leetcode Surrounded Regions(Medium)问题描述:Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’.A region is captured by flipping all 'O’s into 'X’s in that surrounded region将被X包围的O全部变成X,边界上的O不算被包围。Example:X X X X
2020-06-19 09:53:43 163
原创 leetcode python H-Index II(Medium)
leetcode python H-Index II(Medium)问题描述:从一个升序数组中找到一个数h,这个数h满足的要求是数组中最多有h个数字大于这个数,剩下的数都小于这个数。Example:Example:Input: citations = [0,1,3,5,6]Output: 3 Explanation: [0,1,3,5,6] means the researcher has 5 papers in total and each of them had
2020-06-18 21:53:09 142
原创 python-June-Day12-Insert Delete GetRandom O(1)(medium)
Day12-Insert Delete GetRandom O(1)(medium)问题描述:Design a data structure that supports all following operations in average O(1) time.insert(val): Inserts an item val to the set if not already present.remove(val): Removes an item val from the set if prese
2020-06-12 15:46:42 168
原创 python-June-Day11-Sort Colors(medium)
Day11-Sort Colors(medium)问题描述:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1, and 2 to rep
2020-06-11 16:09:43 101
原创 python-June-Day10-Search Insert Position(easy)
Day10-Search Insert Position(easy)问题描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.从一个有序列表中找到target的
2020-06-10 16:40:33 111
原创 python-June-Day9-Is Subsequence Solution(easy)
Day9-Is Subsequence Solution(easy)问题描述:Given a string s and a string t, check if s is subsequence of t.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbin
2020-06-09 17:36:25 149
原创 python-June-Day8-Power of Two(easy)
Day8-Power of Two(easy)问题描述:Given an integer, write a function to determine if it is a power of two.判断一个数是否是2的指数次幂。Example:Example 1:Input: 1Output: true Explanation: 20 = 1Example 2:Input: 16Output: trueExplanation: 24 = 16Example 3:Input
2020-06-08 16:34:12 101
原创 python-June-Day3-Two City Scheduling(easy)
Two City Scheduling(easy)问题描述:There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1].Return the minimum cost to fly every pers
2020-06-04 06:12:13 119
原创 python-June-Day2-Delete Node in a Linked List(easy)
Delete Node in a Linked List(easy)问题描述:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list -- head = [4,5,1,9], which looks like following:从一个单链表中删除元素。Example:Example 1:In
2020-06-02 16:37:30 159
原创 5月挑战Day30- K Closest Points to Origin(Medium)
Day30- K Closest Points to Origin(Medium)问题描述:We have a list of points on the plane. Find the K closest points to the origin (0, 0).(Here, the distance between two points on a plane is the Euclidean distance.)You may return the answer in any order. T
2020-05-31 07:32:32 101
原创 5月挑战Day28- Counting Bits(Medium)
Day28- Counting Bits(Medium)问题描述:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.给一个数num,找到从0-num这些数的二进制中分别有多少个1Example:Exampl
2020-05-28 16:28:14 99
原创 5月挑战Day26-Contiguous Array(Medium)
Day26-Contiguous Array(Medium)问题描述:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.这道题在上个月的挑战里面就有了,求一个数组中最大子数组的长度,这个子数组中0,1的数量相同Example:Example 1:Input: [0,1]Output: 2Explanation: [0, 1] is the lo
2020-05-26 16:43:18 158
原创 5月挑战Day25-Uncrossed Lines(Medium)
Day25-Uncrossed Lines(Medium)问题描述:We write the integers of A and B (in the order they are given) on two separate horizontal lines.Now, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such that:A[i] == B[j];The line w
2020-05-26 09:32:22 151
原创 5月挑战Day24-Construct Binary Search Tree from Preorder Traversal(Medium)
Day24-Construct Binary Search Tree from Preorder Traversal(Medium)问题描述:Return the root node of a binary search tree that matches the given preorder traversal.(Recall that a binary search tree is a binary tree where for every node, any descendant of node
2020-05-24 15:51:50 77
原创 5月挑战Day23-Interval List Intersections(Medium)
Day23-Interval List Intersections(Medium)问题描述:Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order.Return the intersection of these two interval lists.(Formally, a closed interval [a, b] (with a <= b)
2020-05-23 20:56:08 177
原创 5月挑战Day22-Sort Characters By Frequency(Medium)
Day22-Sort Characters By Frequency(Medium)问题描述:Given a string, sort it in decreasing order based on the frequency of characters.给定一个字符串,根据字符出现的频率以降序对其进行排序。Example:Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and
2020-05-22 19:23:45 124
原创 5月挑战Day21-Count Square Submatrices with All Ones(Medium)
Day21-Count Square Submatrices with All Ones(Medium)问题描述:Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.一个0,1矩阵中有多少个有1组成的正方形,这里的正方形的边长可以是1,2,3…到矩阵的长度。正方形中的元素必须是1.Example:Example 1:Input: matrix =[ [0,1,1,
2020-05-21 16:56:01 151
原创 5月挑战Day20-Kth Smallest Element in a BST(Medium)
Day20-Kth Smallest Element in a BST(Medium)问题描述:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.从一个二叉搜索树中找到第k小的数。解法一:通过二叉搜索树的性质求解,左子树
2020-05-20 22:12:14 130
原创 5月挑战Day19-Online Stock Span(Medium)
Day19-Online Stock Span(Medium)问题描述:Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of that stock’s price for the current day.The span of the stock’s price today is defined as the maximum number of conse
2020-05-19 23:33:02 181
原创 5月挑战Day18-Permutation in String(Medium)
Day18-Permutation in String(Medium)问题描述:Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string’s permutations is the substring of the second string.判断S2这个字符串中是否包含由S1组成的子
2020-05-18 16:48:59 96
原创 5月挑战Day17-Find All Anagrams in a String(Medium)
Day17-Find All Anagrams in a String(Medium)问题描述:Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than
2020-05-17 22:28:50 81
原创 5月挑战Day16-Odd Even Linked List(Medium)
Day16-Odd Even Linked List(Medium)问题描述:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in place. The progra
2020-05-17 14:21:41 84
原创 5月挑战Day15-Maximum Sum Circular Subarray(Medium)
Day15-Maximum Sum Circular Subarray(Medium)问题描述:Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C.Here, a circular array means the end of the array connects to the beginning of the array.
2020-05-15 19:55:24 220
原创 5月挑战Day14-Implement Trie (Prefix Tree)(Medium)
Day14-Implement Trie (Prefix Tree)(Medium)问题描述:Implement a trie with insert, search, and startsWith methods.Example:Example:Trie trie = new Trie();trie.insert("apple");trie.search("apple"); // returns truetrie.search("app"); // returns fals
2020-05-14 16:50:13 115
原创 5月挑战Day13-Remove K Digits(Medium)
Day13-Remove K Digits(Medium)问题描述:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 and will be ≥ k.The given num does no
2020-05-13 22:22:04 82
原创 5月挑战Day12-Single Element in a Sorted Array(Medium)
Day11-Single Element in a Sorted Array(Medium)问题描述:You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.从一个
2020-05-12 16:23:24 226
原创 5月挑战Day11-Flood Fill(easy)
Day11-Flood Fill(easy)问题描述:An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a
2020-05-11 17:23:03 181
原创 5月挑战Day10-Find the Town Judge(easy)
Day10-Find the Town Judge问题描述:In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge.If the town judge exists, then:The town judge trusts nobody.Everybody (except for the town judge) t
2020-05-10 21:32:58 149
原创 5月挑战Day9-Valid Perfect Square(easy)
Day9-Valid Perfect Square问题描述:Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.判断一个数是否能够被完全开平方。不能使用内置的函数直接解决。Example:Example 1:Input
2020-05-09 16:17:32 128
原创 5月挑战Day8-Check If It Is a Straight Line(easy)
Day8-Check If It Is a Straight Line问题描述:You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.给一系列坐标,检查这些坐标连成的线是否能形成一条直线。解法:点在同一条直线上的意
2020-05-08 20:02:01 116
原创 5月挑战Day7-Cousins in Binary Tree(easy)
Day7-Cousins in Binary Tree问题描述:In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1.Two nodes of a binary tree are cousins if they have the same depth,...
2020-05-07 20:16:23 113
原创 5月挑战Day6-Majority Element(easy)
Day6-Majority Element问题描述:Given 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 non-empty an...
2020-05-06 16:23:35 161
原创 5月挑战Day5-First Unique Character in a String
Day5-First Unique Character in a String问题描述:Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.从一个字符串中找到第一个唯一的字符,并且返回其下标。Example:s ...
2020-05-05 17:06:44 93
原创 5月挑战Day4-Number Complement
Number Complement问题描述:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation没什么好说的,求补数。Example:Example 1:Input: 5Outpu...
2020-05-04 16:36:48 88
原创 5月挑战Day3-Ransom Note
Day3-Ransom Note问题描述:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed ...
2020-05-03 15:45:43 93
原创 5月挑战Day2-Jewels and Stones
Day2- Jewels and Stones问题描述:You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You wa...
2020-05-02 18:51:34 108
原创 5月挑战Day1-First Bad Version
新的挑战开始了!!!Day1-First Bad Version问题描述You 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...
2020-05-01 17:09:56 141
原创 4月30天leetcode训练-Day30最后一天!!!
Day30-Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree问题描述:Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given ...
2020-04-30 16:22:27 103
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人