自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

roufoo的博客

纸上得来终觉浅 绝知此事要躬行 https://github.com/luqian2017

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

原创 LintCode 575: Decode String (Stack经典难题!)

Decode StringGiven an expression s includes numbers, letters and brackets. Number represents the number of repetitions inside the brackets(can be a string or another expression).Please expand expres...

2019-01-31 17:46:49 465

原创 LintCode 360: Sliding Window Median (双堆 或 双Set, 难题!)

Sliding Window MedianGiven an array of n integer, and a moving window(size k), move the window at each iteration from the start of the array, find the median of the element inside the window at each...

2019-01-31 17:40:52 304

原创 LintCode 107: Word Break (DFS, DP经典题!)

Word BreakGiven a string s and a dictionary of words dict, determine if s can be break into a space-separated sequence of one or more dictionary words.ExampleGiven s = “lintcode”, dict = [“lint”,...

2019-01-03 17:01:36 446 1

原创 LintCode 363: Trapping Rain Water (蓄水池经典题!!!)

Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Trapping Rain WaterExample...

2019-01-02 13:42:22 471

原创 LintCode 384: Longest Substring Without Repeating Characters (字符串处理经典题)

Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.ExampleFor example, the longest substring without repeating let...

2019-01-02 08:52:20 356 1

原创 LintCode 178: Graph Valid Tree (并查集经典题)

Graph Valid TreeGiven n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.ExampleGive...

2019-01-28 07:26:14 332

原创 LintCode1070: Accounts Merge (并查集经典题)

Accounts MergeGiven a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of t...

2019-01-28 02:24:07 363

原创 LintCode 473: Add and Search Word - Data structure design (Trie经典题)

Add and Search Word - Data structure designDesign a data structure that supports the following two operations: addWord(word) and search(word)search(word) can search a literal word or a regular exp...

2019-01-27 03:19:06 255 1

原创 LintCode 434: Number of Islands II (并查集/DFS经典题!!!)

Number of Islands IIGiven a n,m which means the row and column of the 2D matrix and an array of pair A( size k). Originally, the 2D matrix is all 0 which means there is only sea in the matrix. The l...

2019-01-26 17:28:10 473

原创 LintCode 591. Connecting Graph III (并查集经典题!!!)

Connecting Graph IIIGiven n nodes in a graph labeled from 1 to n. There is no edges in the graph at beginning.You need to support the following method:connect(a, b), an edge to connect node a and...

2019-01-23 13:24:14 327

原创 LintCode 590. Connecting Graph II (并查集经典题!!!)

Connecting Graph IIGiven n nodes in a graph labeled from 1 to n. There is no edges in the graph at beginning.You need to support the following method:connect(a, b), an edge to connect node a and ...

2019-01-22 10:54:44 219

原创 LintCode 589: Connecting Graph (并查集经典题!!!)

Connecting GraphGiven n nodes in a graph labeled from 1 to n. There is no edges in the graph at beginning.You need to support the following method:connect(a, b), add an edge to connect node a and...

2019-01-22 09:49:49 459

原创 LintCode 465. Kth Smallest Sum In Two Sorted Arrays (LintCode 401变种,堆经典题)

Kth Smallest Sum In Two Sorted ArraysGiven two integer arrays sorted in ascending order and an integer k. Define sum = a + b, where a is an element from the first array and b is an element from the ...

2019-01-20 11:43:36 579

原创 LintCode 386: Longest Substring with At Most K Distinct Characters (同向双指针经典题!!!)

Longest Substring with At Most K Distinct CharactersGiven a string s, find the length of the longest substring T that contains at most k distinct characters.ExampleFor example, Given s = “eceba”,...

2019-01-20 03:21:59 363 1

原创 LintCode 401. Kth Smallest Number in Sorted Matrix (堆经典好题!!!)

Kth Smallest Number in Sorted MatrixFind the kth smallest number in a row and column sorted matrix.ExampleGiven k = 4 and a matrix:[[1 ,5 ,7],[3 ,7 ,8],[4 ,8 ,9],]return 5ChallengeSolve i...

2019-01-19 16:34:30 417 1

原创 LintCode 406: Minimum Size Subarray Sum (同向双指针经典题!!!)

Minimum Size Subarray SumGiven an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return -1 instead.ExampleG...

2019-01-16 15:53:33 329 1

原创 LintCode 1176: Optimal Division (数学题)

Optimal DivisionGiven 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...

2019-01-13 17:04:12 160

原创 LintCode 1185: Complex Number Multiplication

Complex Number MultiplicationGiven two strings representing two [complex numbers].You need to return a string representing their multiplication. Note i^2 = -1 according to the definition.Example...

2019-01-13 15:50:31 265

原创 LintCode 1198: Most Frequent Subtree Sum

Most Frequent Subtree SumGiven the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree r...

2019-01-13 15:14:19 138

原创 LintCode 1260: Rotate Function (好题)

Rotate FunctionGiven an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F on A as f...

2019-01-13 11:50:42 138

原创 LintCode 551: Nested List Weight Sum

Nested List Weight SumGiven a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list – whose elements may also be i...

2019-01-13 02:28:23 235

原创 LintCode 1310: Product of Array (数组好题)

Product of Array Except SelfGiven an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Example...

2019-01-11 13:46:52 137 1

原创 LintCode 12: Min Stack (数据结构经典题)

Min StackImplement a stack with min() function, which will return the smallest number in the stack.It should support push, pop and min operation all in O(1) cost.Examplepush(1)pop() // return...

2019-01-10 17:15:54 266 1

原创 LintCode 597: Subtree with MaximumAverage (Binary Tree经典题)

Subtree with Maximum AverageGiven a binary tree, find the subtree with maximum average. Return the root of the subtree.ExampleGiven a binary tree: 1/ -5 11/ \ / 1 2 4 -2retur...

2019-01-10 16:52:53 873

原创 LintCode 661: Convert BST to Greater Tree (BST好题)

Convert BST to Greater TreeGiven 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...

2019-01-10 01:39:52 105

原创 LintCode 647: Find All Anagrams in a String (滑动窗口经典题!!!)

Find All Anagrams in a StringGiven 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 st...

2019-01-08 14:46:02 358 1

原创 LintCode 646:First Position Unique Character

First Position Unique CharacterGiven a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.ExampleGiven s = “lintcode”, return 0.Given s = ...

2019-01-06 16:30:35 112

原创 LintCode 807: Palindrome Number II

Palindrome Number IIDetermines whether a binary representation of a non-negative integer n is a palindromeExampleGiven n = 0, return TrueExplanation:The binary representation of 0 is: 0Given n...

2019-01-06 02:45:39 125

原创 LintCode 983: Baseball Game

Baseball GameYou’re now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round’s score): Directly represents the number of poin...

2019-01-06 02:28:57 100

原创 LintCode 1038: Jewels And Stones

Jewels And StonesYou’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 ho...

2019-01-06 01:36:14 120

原创 LintCode 1054: Min Cost Climbing Stairs (DP题)

Min Cost Climbing StairsOn a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum...

2019-01-06 01:25:57 105 1

原创 LintCode 1112: Set Mismatch (XOR经典题)

Set MismatchThe set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in r...

2019-01-01 14:46:41 293

原创 LintCode 1126: Merge Two Binary Trees (二叉树经典题)

Merge Two Binary TreesGiven two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge the...

2019-01-01 13:19:39 187 1

原创 LintCode 1137: Construct String from Binary Tree (经典二叉树题目)

Construct String from Binary TreeYou need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to be represented by em...

2019-01-01 10:14:30 183

原创 LintCode 1187: K-diff Pairs in an Array (同向双指针)

K-diff Pairs in an ArrayGiven an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i...

2019-01-01 09:48:23 171

原创 LintCode 1227: Repeated Substring Pattern

Repeated Substring PatternGiven a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string...

2019-01-01 09:22:15 203

原创 LintCode 1354: Pascal's Triangle II

LintCode-LogoHomeAlgorithmsAICATnewVIPLanguageavatarroufooBack1354. Pascal’s Triangle IIDescriptionGiven a non-negative index k where k ≤ 33, return the kth index row of the Pascal’s triang...

2019-01-01 06:39:38 153

原创 LintCode 1369: Most Common Word

Most Common WordGiven a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn’t banned, an...

2019-01-01 04:34:41 408

空空如也

空空如也

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

TA关注的人

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