自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 收藏
  • 关注

原创 Leetcode May Challenge - 05/31: Edit Distance(Python)

题目描述 Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: Insert a character Delete a character Replace a character 例子 Example 1: Input: word1 =

2020-06-01 03:34:06 151

原创 Leetcode May Challenge - 05/30: K Closest Points to Origin(Python)

题目描述 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. The answer is guaranteed to be unique (excep

2020-05-30 19:51:54 139

原创 Leetcode May Challenge - 05/29: Course Schedule(Python)

题目描述 There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of

2020-05-30 00:37:21 92

原创 Leetcode May Challenge - 05/28: Counting Bits(Python)

题目描述 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. Follow up: It is very easy to come up with a solution with run time O(n*sizeo

2020-05-28 21:46:06 95

原创 Leetcode May Challenge - 05/27: Possible Bipartition(Python)

题目描述 Given a set of N people (numbered 1, 2, …, N), we would like to split everyone into two groups of any size. Each person may dislike some other people, and they should not go into the same group. Formally, if dislikes[i] = [a, b], it means it is not al

2020-05-28 06:56:35 121

原创 Leetcode May Challenge - 05/26: Contiguous Array(Python)

题目描述 Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. 例子 Example 1: Input: [0,1] Output: 2 Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1. Example 2: Input: [0,1,0] O

2020-05-27 02:21:46 77

原创 Leetcode May Challenge - 05/25: Uncrossed Lines(Python)

题目描述 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 we draw does not intersect any o

2020-05-27 02:13:31 163

原创 Leetcode May Challenge - 05/24: Construct Binary Search Tree from Preorder Traversal(Python)

题目描述 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.left has a value < node.val, and any descendant of node.right ha

2020-05-27 01:59:12 136

原创 Leetcode May Challenge - 05/23: Interval List Intersections(Python)

题目描述 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) denotes the set of real numbers x with a &l

2020-05-24 03:38:21 91

原创 Leetcode May Challenge - 05/22: Sort Characters By Frequency(Python)

题目描述 Given a string, sort it in decreasing order based on the frequency of characters. 例子 Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must appear before both 'r' and 't'. Therefore "ee

2020-05-23 06:37:30 113

原创 Leetcode May Challenge - 05/21: Count Square Submatrices with All Ones(Python)

题目描述 Given a m * n matrix of ones and zeros, return how many square submatrices have all ones. 例子 Example 1: Input: matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1] ] Output: 15 Explanation: There are 10 squares of side 1. There are 4 squares of side 2. T

2020-05-21 21:27:41 144

原创 刷题日志:Leetcode 62 63 Unique Paths系列(Python)

前言 Unique Paths在leetcode中有两道题,是动态规划比较经典的题型。本文将对这两道题的做法进行讲解。 62 Unique Paths 题目描述 A 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. The robot

2020-05-21 09:09:42 180

原创 Leetcode May Challenge - 05/20: Kth Smallest Element in a BST(Python)

题目描述 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. 例子 Example 1: Input: root = [3,1,4,null,2], k = 1 3 / \ 1 4 \ 2 Output:

2020-05-20 21:02:39 90

原创 Leetcode May Challenge - 05/19: Online Stock Span(Python)

题目描述 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 consecutive days (starting from today

2020-05-20 03:47:50 134

原创 Leetcode May Challenge - 05/18: Permutation in String(Python)

题目描述 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. Note: The input strings only contain lower case letters. T

2020-05-19 08:08:37 77

原创 Leetcode May Challenge - 05/17: Find All Anagrams in a String(Python)

题目描述 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 20,100. The order of output does not matter.

2020-05-17 21:21:12 87

原创 Leetcode May Challenge - 05/16: Odd Even Linked List(Python)

题目描述 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 program should run in O(1) space complexit

2020-05-16 21:23:49 307

原创 Leetcode May Challenge - 05/15: Maximum Sum Circular Subarray(Python)

题目描述 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. ** (Formally, C[i] = A[i] when 0 <= i <

2020-05-16 05:31:31 157

原创 Leetcode May Challenge - 05/14: Implement Trie (Prefix Tree)(Python)

题目描述 Implement a trie with insert, search, and startsWith methods. Note: You may assume that all inputs are consist of lowercase letters a-z. All inputs are guaranteed to be non-empty strings. 例子 Trie trie = new Trie(); trie.insert(“apple”); trie.search(“a

2020-05-16 05:12:58 84

原创 Leetcode May Challenge - 05/13: Remove K Digits(Python)

题目描述 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 not contain any leading zero. 例子

2020-05-14 09:01:48 76

原创 Leetcode May Challenge - 05/12: Single Element in a Sorted Array(Python)

题目描述 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. Note: Your solution should run in O(log n) time and

2020-05-12 21:59:28 72

原创 Leetcode May Challenge - 05/11: Flood Fill(Python)

题目描述 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 pixel value newColor, “

2020-05-11 22:28:54 100

原创 Leetcode May Challenge - 05/10: Find the Town Judge(Python)

题目描述 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: 1 The town judge trusts nobody. 2 Everybody (except for the town judge) trusts the town judge. 3

2020-05-10 20:06:32 108

原创 Leetcode May Challenge - 05/09: Valid Perfect Square(Python)

题目描述 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 1: Input: 16 Output: true Example 2: Input: 14 Output: false 解释 给一个数字,要求在不

2020-05-09 21:53:26 73

原创 Leetcode May Challenge - 05/08: Check If It Is a Straight Line(Python)

题目描述 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. Constraints: 2 <= coordinates.length <= 1000 coordinates[i].length == 2 -

2020-05-08 21:04:35 94

原创 Leetcode May Challenge - 05/07: Cousins in Binary Tree(Python)

题目描述 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, but have different parents. ...

2020-05-08 03:46:25 232

原创 Leetcode May Challenge - 05/06: Majority Element(Python)

题目描述 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 and the majority element ...

2020-05-06 20:52:39 96

原创 Leetcode May Challenge - 05/05: First Unique Character in a String(Python)

题目描述 Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. 例子 s = “leetcode” return 0. s = “loveleetcode”, return 2. 解释 给一个字符串,返回第一个只出现过一次...

2020-05-05 20:37:45 89

原创 Leetcode May Challenge - 05/04: Number Complement(Python)

题目描述 Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. 例子 Example 1: Input: 5 Output: 2 Explanation: The binary represe...

2020-05-04 23:02:53 99

原创 Leetcode May Challenge - 05/03: Ransom Note(Python)

题目描述 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 from the magazines...

2020-05-03 21:39:28 78

原创 刷题日志:Leetcode 79 Word Search(Python)

题目描述 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertical...

2020-05-03 07:53:44 203

原创 Leetcode May Challenge - 05/02: Jewels and Stones(Python)

题目描述 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 want to know how many of th...

2020-05-02 22:41:03 113

原创 Leetcode May Challenge - 05/01: First Bad Version(Python)

题目描述 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 each version is developed based o...

2020-05-02 08:34:32 107

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除