自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

leetcode 解题思路

FLAG必经之路

  • 博客(62)
  • 收藏
  • 关注

原创 Permutation Index

Given a permutation which contains no repeated number, find its index in all the permutations of these numbers, which are ordered in lexicographical order. The index begins at 1.ExampleExample 1:...

2019-12-30 12:23:49 271

原创 K Sum II

Given n unique postive integers, number k (1<=k<=n) and target.Find all possible k integers where their sum is target.ExampleExample 1:Input: [1,2,3,4], k = 2, target = 5Output: [[1,4...

2019-12-30 06:43:53 114

原创 String Permutation II

Given a string, find all permutations of it without duplicates.ExampleExample 1:Input: "abb"Output:["abb", "bab", "bba"]Example 2:Input: "aabb"Output:["aabb", "abab", "baba", "bbaa", ...

2019-12-30 06:02:47 187

原创 String Permutation

Given two strings, write a method to decide if one is a permutation of the other.ExampleExample 1: Input: "abcd", "bcad" Output: TrueExample 2: Input: "aac", "abc" Output: False思路:cou...

2019-12-30 05:47:25 133

原创 Substring with At Least K Distinct Characters

Given a stringSwith only lowercase characters.Return the number of substrings that contains at leastkdistinct characters.ExampleExample 1:Input: S = "abcabcabca", k = 4Output: 0Explanat...

2019-12-28 14:48:03 129

原创 Triangle Count

Given an array of integers, how many three numbers can be found in the array, so that we can build an triangle whose three edges length is the three numbers that we find?ExampleExample 1:Inp...

2019-12-28 13:55:43 169

原创 Valid Palindrome II

Given a non-empty strings, you may delete at most one character. Judge whether you can make it a palindrome.ExampleExample 1:Input: s = "aba"Output: trueExplanation: Originally a palindrome....

2019-12-28 13:10:24 161

原创 Two Sum - Difference equals to target

Given an array of integers, find two numbers that theirdifferenceequals to a target value.where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are ...

2019-12-28 12:38:03 132

原创 Two Sum - Less than or equal to target

Given an array of integers, find how many pairs in the array such that their sum isless than or equal toa specific target number. Please return the number of pairs.ExampleExample 1:Input: num...

2019-12-28 09:22:55 144

原创 Two Sum - Greater Than Target

Given an array of integers, find how many pairs in the array such that their sum is bigger than a specific target number. Please return the number of pairs.ExampleExample 1:Input: [2, 7, 11, 15...

2019-12-28 09:13:55 122

原创 Two Sum - Closest to target

Given an arraynumsofnintegers, find two integers innumssuch that the sum is closest to a given number,target.Return the absolute value of difference between the sum of the two integers and th...

2019-12-28 08:54:58 163

原创 Two Sum - Unique Pairs

Given an array of integers, find how manyunique pairsin the array such that their sum is equal to a specific target number. Please return the number of pairs.ExampleExample 1:Input: nums = [1...

2019-12-28 08:49:36 207

原创 Sort an Array

Given an integer array, sort it in ascending order. Use selection sort, bubble sort, insertion sort or any O(n2) algorithm.ExampleExample 1: Input: [3, 2, 1, 4, 5] Output: [1, 2, 3, 4, 5] E...

2019-12-27 13:36:29 216

原创 Window Sum

Given an array of n integers, and a moving window(size k), move the window at each iteration from the start of the array, find thesumof the element inside the window at each moving.ExampleExampl...

2019-12-27 09:23:56 378

原创 Path Sum II

Your are given a binary tree in which each node contains a value. Design an algorithm to get all paths which sum to a given value. The path does not need to start or end at the root or a leaf, but it ...

2019-12-25 14:18:02 95

原创 Binary Tree Path Sum

Given a binary tree, find all paths that sum of the nodes in the path equals to a given numbertarget.A valid path is from root node to any of the leaf nodes.ExampleExample 1:Input:{1,2,4,2,...

2019-12-25 13:48:26 138

原创 Smallest Rectangle Enclosing Black Pixels

An image is represented by a binary matrix with0as a white pixel and1as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontally and v...

2019-12-24 13:52:37 152

原创 Search for a Range

Given a sorted array ofnintegers, find the starting and ending position of a given target value.If the target is not found in the array, return[-1, -1].ExampleExample 1:Input:[]9Output:...

2019-12-23 14:25:02 102

原创 Total Occurrence of Target

Given a target number and an integer array sorted in ascending order. Find the total number of occurrences of target in the array.ExampleExample1:Input: [1, 3, 3, 4, 5] and target = 3, Output:...

2019-12-23 13:46:15 164

原创 drop eggs

There is a building ofnfloors. If an egg drops from thekth floor or above, it will break. If it's dropped from any floor below, it will not break.You're given two eggs, Findkwhile minimize the...

2019-12-23 10:23:32 269

原创 Build Post Office II

Given a 2D grid, each cell is either a wall2, an house1or empty0(the number zero, one, two), find a place to build a post office so that the sum of the distance from the post office to all the ho...

2019-12-22 08:55:19 418

原创 The Maze

There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rollingup,down,leftorright,but it won't stop rolling until hitting a wall. When the ball stops, it ...

2019-12-22 05:30:46 253

原创 Zombie in Matrix

Given a 2D grid, each cell is either a wall2, a zombie1or people0(the number zero, one, two).Zombies can turn the nearest people(up/down/left/right) into zombies every day, but can not through wa...

2019-12-22 04:53:28 245

原创 Search Graph Nodes

Given aundirected graph, anodeand atarget, return the nearest node to given node which value of it is target, returnNULLif you can't find.There is amappingstore the nodes' values in the give...

2019-12-22 02:27:23 149

原创 Connected Component in Undirected Graph

Find connected component in undirected graph.Each node in the graph contains a label and a list of its neighbors.(A connected component of an undirected graph is a subgraph in which any two vertic...

2019-12-22 02:11:30 303

原创 Rotate String II

Given a string(Given in the way of char array), a right offset and a left offset, rotate the string by offset in place.(left offest represents the offset of a string to the left,right offest represent...

2019-12-20 12:54:54 173

原创 Longest Palindromic Subsequence

Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is1000.ExampleExample1Input: "bbbab"Output: 4Explanation:One possible l...

2019-12-19 12:33:42 336

原创 Verifying an Alien Dictionary

In an alien language, surprisingly they also use english lowercase letters, but possiblyin a differentorder. Theorderof the alphabetis some permutationof lowercase letters.Given a sequence of...

2019-12-18 10:58:20 216

原创 Sliding Window Matrix Maximum

Given an array ofn * mmatrix, and a moving matrix window (sizek * k), move the window from top left to botton right at each iteration, find the maximum sum inside the window at each moving.Return...

2019-12-17 13:43:30 155

原创 Nuts bolts problem

Given a set ofnnuts of different sizes andnbolts of different sizes. There is a one-one mapping between nuts and bolts.Comparison of a nut to another nut or a bolt to another bolt isnot allowed...

2019-12-17 12:17:37 649

原创 Submatrix Sum

Given an integer matrix, find a submatrix where the sum of numbers is zero. Your code should return the coordinate of the left-up and right-down number.If there are multiple answers, you can return ...

2019-12-16 14:01:23 409

原创 Subarray Sum Closest

Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number.ExampleExample1Input: [-3,1,1,-3,5] Output: [0,2]Explanation: [0,2],...

2019-12-16 12:27:30 240 1

原创 Continuous Subarray Sum II

Given an circular integer array (the next element of the last element is the first element), find a continuous subarray in it, where the sum of numbers is the biggest. Your code should return the inde...

2019-12-16 10:20:43 104

原创 [LintCode] Continuous Subarray Sum

Given an integer array, find a continuous subarray where the sum of numbers is the biggest. Your code should return the index of the first number and the index of the last number. (If their are duplic...

2019-12-16 09:51:26 152

原创 Subarray Sum II

Given an positive integer arrayAand an interval. Return the number of subarrays whose sum is in the range of given interval.ExampleExample 1:Input: A = [1, 2, 3, 4], start = 1, end = 3Output...

2019-12-16 03:26:39 294

原创 Subarray Sum

Given an integer array, find a subarray where the sum of numbers iszero. Your code should return the index of the first number and the index of the last number.ExampleExample 1:Input: [-3, 1,...

2019-12-15 11:54:14 310

原创 Flatten List

Given a list, each element in the list can be a list or integer. flatten it into a simply list with integers.ExampleExample 1: Input: [[1,1],2,[1,1]] Output: [1,1,2,1,1] Explanation: flatt...

2019-12-15 08:04:01 147

原创 K Sum

Givenndistinct positive integers, integerk(k<=n) and a numbertarget.Findknumbers where sum is target. Calculate how many solutions there are?ExampleExample 1Input:List = [1,2,3,4...

2019-12-14 13:39:14 137

原创 Coins in a Line III

There arencoins in a line, and value ofi-thcoin isvalues[i].Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger...

2019-12-14 12:10:57 219

原创 [lintcode] Stone Game II

There is a stone game.At the beginning of the game the player picks n piles of stonesin a circle.The goal is to merge the stones in one pile observing the following rules:At each step of the game...

2019-12-14 11:28:21 188

空空如也

空空如也

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

TA关注的人

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