LeetCode
orientliu96
一直努力成长的小菜鸡
展开
-
LeetCode 216. Combination Sum III 解题报告(python)
216. Combination Sum IIICombination Sum III题目描述Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should b...原创 2020-03-14 09:16:22 · 377 阅读 · 0 评论 -
LeetCode 648. Replace Words 解题报告(python)
648. Replace WordsReplace Words python solution题目描述In English, we have a concept called root, which can be followed by some other words to form another longer word - let’s call this word successo...原创 2020-02-26 17:46:14 · 293 阅读 · 0 评论 -
LeetCode 947. Most Stones Removed with Same Row or Column 解题报告(python)
947. Most Stones Removed with Same Row or ColumnMost Stones Removed with Same Row or Column python solution题目描述On a 2D plane, we place stones at some integer coordinate points. Each coordinate p...原创 2020-02-25 13:27:55 · 292 阅读 · 0 评论 -
LeetCode 684. Redundant Connection 解题报告(python)
684. Redundant ConnectionRedundant Connection python solution题目描述n this problem, a tree is an undirected graph that is connected and has no cycles.The given input is a graph that started as a tr...原创 2020-02-22 23:27:02 · 299 阅读 · 0 评论 -
LeetCode 1023. Camelcase Matching 解题报告(python)
1023. Camelcase MatchingCamelcase Matching python solution题目描述A query word matches a given pattern if we can insert lowercase letters to the pattern word so that it equals the query. (We may inse...原创 2020-02-21 10:27:33 · 291 阅读 · 0 评论 -
LeetCode 1020. Number of Enclaves 解题报告(python)
1020. Number of EnclavesNumber of Enclaves python solution题目描述Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land)A move consists of walking from one land square 4-dire...原创 2020-02-20 10:25:30 · 300 阅读 · 0 评论 -
LeetCode 230. Kth Smallest Element in a BST 解题报告(python)
230. Kth Smallest Element in a BSTKth Smallest Element in a BST python solution题目描述Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note:You may a...原创 2020-02-19 12:41:22 · 487 阅读 · 0 评论 -
LeetCode 1031. Maximum Sum of Two Non-Overlapping Subarrays 解题报告(python)
1031. Maximum Sum of Two Non-Overlapping SubarraysMaximum Sum of Two Non-Overlapping Subarrays python solution题目描述Given an array A of non-negative integers, return the maximum sum of elements in ...原创 2020-02-18 12:49:44 · 474 阅读 · 0 评论 -
LeetCode 835. Image Overlap 解题报告(python)
835. Image OverlapImage Overlap python solution题目描述Two images A and B are given, represented as binary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.)We trans...原创 2020-02-17 13:01:34 · 392 阅读 · 0 评论 -
LeetCode 1233. Remove Sub-Folders from the Filesystem 解题报告(python)
1233. Remove Sub-Folders from the FilesystemRemove Sub-Folders from the Filesystem python solution题目描述Given a list of folders, remove all sub-folders in those folders and return in any order the ...原创 2020-02-14 19:58:05 · 490 阅读 · 0 评论 -
LeetCode 553. Optimal Division 解题报告(python)
553. Optimal DivisionOptimal Division python solution题目描述Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, y...原创 2020-02-13 23:47:40 · 210 阅读 · 0 评论 -
LeetCode 919. Complete Binary Tree Inserter解题报告(python)
919. Complete Binary Tree InserterComplete Binary Tree Inserter python solution题目描述A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, an...原创 2020-02-12 20:41:51 · 281 阅读 · 0 评论 -
LeetCode 1011. Capacity To Ship Packages Within D Days(python)
1011. Capacity To Ship Packages Within D DaysCapacity To Ship Packages Within D Days python solution题目描述A conveyor belt has packages that must be shipped from one port to another within D days.T...原创 2020-02-11 11:47:12 · 368 阅读 · 0 评论 -
LeetCode 817. Linked List Components 解题报告(python)
817. Linked List ComponentsLinked List Components python solution题目描述We are given head, the head node of a linked list containing unique integer values.We are also given the list G, a subset of ...原创 2020-02-10 11:20:45 · 302 阅读 · 0 评论 -
LeetCode 1004. Max Consecutive Ones III 解题报告(python)
1004. Max Consecutive Ones IIIMax Consecutive Ones III python solution题目描述Given an array A of 0s and 1s, we may change up to K values from 0 to 1.Return the length of the longest (contiguous) su...原创 2020-02-09 12:07:50 · 900 阅读 · 0 评论 -
LeetCode 508. Most Frequent Subtree Sum 解题报告(python)
508. Most Frequent Subtree SumMost Frequent Subtree Sum python solution题目描述Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as t...原创 2020-02-08 16:07:02 · 275 阅读 · 0 评论 -
LeetCode 932. Beautiful Array解题报告(python)
932. Beautiful ArrayBeautiful Array python solution题目描述For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, …, N, such that:For every i < j, there is no k wi...原创 2020-02-07 18:04:04 · 522 阅读 · 0 评论 -
LeetCode 547. Friend Circles 解题报告(python)
547. Friend CirclesFriend Circles python solution题目描述There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is ...原创 2020-02-06 18:51:13 · 706 阅读 · 0 评论 -
LeetCode 1094. Car Pooling 解题报告(python)
1094. Car PoolingCar Pooling python solution题目描述You are driving a vehicle that has capacity empty seats initially available for passengers. The vehicle only drives east (ie. it cannot turn aroun...原创 2020-02-05 18:11:29 · 820 阅读 · 0 评论 -
LeetCode 789. Escape The Ghosts 解题报告(python)
789. Escape The GhostsEscape The Ghosts python solution题目描述You are playing a simplified Pacman game. You start at the point (0, 0), and your destination is (target[0], target[1]). There are sever...原创 2020-02-04 23:23:40 · 246 阅读 · 0 评论 -
LeetCode 529. Minesweeper 解题报告(python)
529. MinesweeperFizz Buzz Multithreaded python solution题目描述Let’s play the minesweeper game (Wikipedia, online game)!You are given a 2D char matrix representing the game board. ‘M’ represents an ...原创 2020-02-03 21:50:32 · 496 阅读 · 0 评论 -
LeetCode 712. Minimum ASCII Delete Sum for Two Strings 解题报告(python)
712. Minimum ASCII Delete Sum for Two StringsMinimum ASCII Delete Sum for Two Strings python solution题目描述Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two stri...原创 2020-02-02 17:38:19 · 233 阅读 · 0 评论 -
LeetCode 1019. Next Greater Node In Linked List 解题报告(python)
1019. Next Greater Node In Linked ListNext Greater Node In Linked List python solution题目描述We are given a linked list with head as the first node. Let’s number the nodes in the list: node_1, node...原创 2020-02-01 12:15:47 · 312 阅读 · 0 评论 -
LeetCode 1209. Remove All Adjacent Duplicates in String II解题报告(python)
1209. Remove All Adjacent Duplicates in String IIRemove All Adjacent Duplicates in String II python solution题目描述Given a string s, a k duplicate removal consists of choosing k adjacent and equal l...原创 2020-01-31 11:39:05 · 951 阅读 · 0 评论 -
LeetCode 413. Arithmetic Slices解题报告(python)
413. Arithmetic SlicesArithmetic Slices python solution题目描述A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive el...原创 2020-01-30 18:13:41 · 308 阅读 · 0 评论 -
LeetCode 78. Subsets 解题报告(python)
78. SubsetsSubsets python solution题目描述Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.解析题目中有条很关键的...原创 2020-01-29 10:55:52 · 311 阅读 · 0 评论 -
LeetCode 1268. Search Suggestions System 解题报告(python)
1268. Search Suggestions SystemSearch Suggestions System python solution题目描述Given an array of strings products and a string searchWord. We want to design a system that suggests at most three prod...原创 2020-01-28 19:37:03 · 1213 阅读 · 0 评论 -
LeetCode 1105. Filling Bookcase Shelves 解题报告(python)
1105. Filling Bookcase ShelvesFilling Bookcase Shelves python solution题目描述We have a sequence of books: the i-th book has thickness books[i][0] and height books[i][1].We want to place these books...原创 2020-01-22 17:08:39 · 574 阅读 · 0 评论 -
LeetCode 540. Single Element in a Sorted Array 解题报告(python)
540. Single Element in a Sorted ArraySingle Element in a Sorted Array python solution题目描述You are given a sorted array consisting of only integers where every element appears exactly twice, except...原创 2020-01-20 10:39:38 · 252 阅读 · 0 评论 -
Leetcode 1115. Print FooBar Alternately解题报告(python)
1115. Print FooBar AlternatelyPrint FooBar Alternately python solution题目描述解析多线程操作的题目,思路比较简单,使用Lock在Lock.acquire() Lock.release()之间的程序,是不会被其他线程所调用的。// An highlighted blockfrom threading impor...原创 2020-01-16 11:29:17 · 538 阅读 · 0 评论 -
LeetCode 609. Find Duplicate File in System解题报告(python)
609. Find Duplicate File in SystemFind Duplicate File in System python solution题目描述Given a list of directory info including directory path, and all the files with contents in this directory, you ...原创 2020-01-15 15:11:45 · 245 阅读 · 0 评论 -
LeetCode 1017. Convert to Base -2解题报告(python)
1017. Convert to Base -2Convert to Base -2 python solution题目描述Given a number N, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two).The returned strin...原创 2020-01-14 10:27:20 · 244 阅读 · 0 评论 -
Leetcode 983. Minimum Cost For Tickets解题报告(python)
1111. 983. Minimum Cost For TicketsMinimum Cost For Tickets python solution题目描述In a country popular for train travel, you have planned some train travelling one year in advance. The days of the ...原创 2020-01-12 21:40:52 · 367 阅读 · 0 评论 -
LeetCode 1143. Longest Common Subsequence解题报告(python)
1143. Longest Common SubsequenceLongest Common Subsequence python solution题目描述Given two strings text1 and text2, return the length of their longest common subsequence.A subsequence of a string i...原创 2020-01-09 12:45:07 · 1462 阅读 · 0 评论 -
LeetCode 1090. Largest Values From Labels解题报告(python)
1090. Largest Values From LabelsLargest Values From Labels python solution题目描述We have a set of items: the i-th item has value values[i] and label labels[i].Then, we choose a subset S of these it...原创 2020-01-08 22:18:06 · 245 阅读 · 0 评论 -
LeetCode 238. Product of Array Except Self解题报告(python)
238. Product of Array Except SelfProduct of Array Except Self python solution题目描述Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the prod...原创 2020-01-07 12:40:53 · 233 阅读 · 0 评论 -
LeetCode 1247. Minimum Swaps to Make Strings Equals解题报告(python)
1247. Minimum Swaps to Make Strings EqualMinimum Swaps to Make Strings Equal python solution题目描述You are given two strings s1 and s2 of equal length consisting of letters “x” and “y” only. Your ta...原创 2020-01-07 09:03:34 · 591 阅读 · 0 评论 -
LeetCode 1267. Count Servers that Communicate解题报告(python)
1267. Count Servers that CommunicateCount Servers that Communicatepython solution题目描述You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that...原创 2020-01-05 23:37:24 · 723 阅读 · 0 评论 -
LeetCode 347. Top K Frequent Elements解题报告(python)
347. Top K Frequent ElementsTop K Frequent Elements python solution题目描述Given a non-empty array of integers, return the k most frequent elements.解析和LeetCode 451. Sort Characters By Frequency属于一...原创 2020-01-04 16:45:32 · 360 阅读 · 0 评论 -
LeetCode 451. Sort Characters By Frequency解题报告(python)
451. Sort Characters By FrequencySort Characters By Frequency python solution题目描述Given a string, sort it in decreasing order based on the frequency of characters.解析解题思路比较简单,见代码class Solution...原创 2020-01-03 20:24:00 · 246 阅读 · 0 评论