- 博客(84)
- 收藏
- 关注
原创 [Leetcode] 587. Erect the Fence 解题报告
题目:There are some trees, where each tree is represented by (x,y) coordinate in a two-dimensional garden. Your job is to fence the entire garden using the minimum length of rope as it is expensiv
2017-12-31 12:21:45 1005
原创 [Leetcode] 583. Delete Operation for Two Strings 解题报告
题目:Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string.Example 1:
2017-12-31 11:24:49 262
原创 [Leetcode] 582. Kill Process 解题报告
题目:Given 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-12-28 16:57:11 910
原创 [Leetcode] 581. Shortest Unsorted Continuous Subarray 解题报告
题目:Given 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 ne
2017-12-28 15:43:38 399
原创 [Leetcode] 576. Out of Boundary Paths 解题报告
题目:There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary in four directions (up, down, left, righ
2017-12-26 12:58:20 433
原创 [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 distrib
2017-12-26 11:19:55 264
原创 [Leetcode] 573. Squirrel Simulation 解题报告
题目:There's a tree, a squirrel, and several nuts. Positions are represented by the cells in a 2D grid. Your goal is to find the minimal distance for the squirrel to collect all the nuts and put the
2017-12-26 10:55:21 642
原创 [Leetcode] 572. Subtree of Another Tree 解题报告
题目:Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all o
2017-12-25 21:26:59 198
原创 [Leetcode] 568. Maximum Vacation Days 解题报告
题目:LeetCode wants to give one of its best employees the option to travel among N cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in
2017-12-25 21:00:46 981
原创 [Leetcode] 567. Permutation in String 解题报告
题目: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 st
2017-12-25 12:36:04 495
原创 [Leetcode] 566. Reshape the Matrix 解题报告
题目:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.You're given a matrix represented by
2017-12-25 11:19:21 249
原创 [Leetcode] 565. Array Nesting 解题报告
题目:A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below
2017-12-25 10:31:14 358
原创 [Leetcode] 564. Find the Closest Palindrome 解题报告
题目:Given an integer n, find the closest integer (not including itself), which is a palindrome.The 'closest' is defined as absolute difference minimized between two integers.Example 1:
2017-12-25 09:56:18 2038 2
原创 [Leetcode] 563. Binary Tree Tilt 解题报告
题目:Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all rig
2017-12-25 09:41:33 329
原创 [Leetcode] 562. Longest Line of Consecutive One in Matrix 解题报告
题目:Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal.Example:Input:[[0,1,1,0], [0,1,1,0], [0
2017-12-24 09:41:22 1228
原创 [Leetcode] 561. Array Partition I 解题报告
题目:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n
2017-12-24 09:35:37 241
原创 [Leetcode] 560. Subarray Sum Equals K 解题报告
题目:Given 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 = 2Output: 2No
2017-12-24 09:08:55 314
原创 [Leetcode] 557. Reverse Words in a String III 解题报告
题目:Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCo
2017-12-23 22:02:17 222
原创 [Leetcode] 556. Next Greater Element III 解题报告
题目:Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer nand is greater in value than n. If no such positiv
2017-12-23 21:26:12 509
原创 [Leetcode] 555. Split Concatenated Strings 解题报告
题目:Given a list of strings, you could concatenate these strings together into a loop, where for each string you could choose to reverse it or not. Among all the possible loops, you need to find
2017-12-23 20:08:23 1568
原创 [Leetcode] 554. Brick Wall 解题报告
题目:There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the t
2017-12-23 17:59:30 347
原创 [Leetcode] 553. Optimal Division 解题报告
题目:Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of parenthesis at any position
2017-12-23 17:51:47 257
原创 [Leetcode] 552. Student Attendance Record II 解题报告
题目:Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 +
2017-12-23 16:28:47 1147
原创 [Leetcode] 551. Student Attendance Record I 解题报告
题目:You are given a string representing an attendance record for a student. The record only contains the following three characters:'A' : Absent.'L' : Late.'P' : Present.A student cou
2017-12-23 10:08:52 356
原创 [Leetcode] 549. Binary Tree Longest Consecutive Sequence II 解题报告
题目:Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree.Especially, this path can be either increasing or decreasing. For example, [1,2,3,4] and [4,3,2
2017-12-22 09:28:20 1056
原创 [Leetcode] 548. Split Array with Equal Sum 解题报告
题目:Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies following conditions:0 Sum of subarrays (0, i - 1), (i + 1, j - 1), (j + 1, k - 1) and (k
2017-12-21 21:19:57 1562
原创 [Leetcode] 547. Friend Circles 解题报告
题目: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 a direct friend of B, and B is a direct friend
2017-12-21 20:34:11 524
原创 [Leetcode] 546. Remove Boxes 解题报告
题目:Given several boxes with different colors represented by different positive numbers. You may experience several rounds to remove boxes until there is no box left. Each time you can choose s
2017-12-21 17:58:08 1319
原创 [Leetcode] 545. Boundary of Binary Tree 解题报告
题目:Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, and right boundary in order without duplicate n
2017-12-21 14:07:29 1090
原创 [Leetcode] 544. Output Contest Matches 解题报告
题目:During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good strategy to make
2017-12-21 13:43:50 522
原创 [Leetcode] 543. Diameter of Binary Tree 解题报告
题目:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath between any two nodes in a tree. This path may
2017-12-21 10:27:21 244
原创 [Leetcode] 542. 01 Matrix 解题报告
题目:Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1.Example 1: Input:0 0 00 1 00 0 0Output:0 0 0
2017-12-21 09:15:04 952
原创 [Leetcode] 541. Reverse String II 解题报告
题目:Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all
2017-12-20 22:40:37 251
原创 [Leetcode] 540. Single Element in a Sorted Array 解题报告
题目:Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element that appears only once.Example 1:
2017-12-20 22:36:35 254
原创 [Leetcode] 539. Minimum Time Difference 解题报告
题目:Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list.Example 1:Input: ["23:59","00:00"]Output
2017-12-20 12:07:25 286
原创 [Leetcode] 538. Convert BST to Greater Tree 解题报告
题目:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST
2017-12-20 11:35:43 210
原创 [Leetcode] 537. Complex Number Multiplication 解题报告
题目:Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:Input: "1+1i",
2017-12-20 11:18:06 209
原创 [Leetcode] 536. Construct Binary Tree from String 解题报告
题目:You need to construct a binary tree from a string consisting of parenthesis and integers.The whole input represents a binary tree. It contains an integer followed by zero, one or two pair
2017-12-20 10:52:18 1195
原创 [Leetcode] 535. Encode and Decode TinyURL 解题报告
题目: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-t
2017-12-20 10:09:46 239
原创 [Leetcode] 533. Lonely Pixel II 解题报告
题目:Given a picture consisting of black and white pixels, and a positive integer N, find the number of black pixels located at some specific row R and column C that align with all the following
2017-12-20 09:38:04 926
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人