自定义博客皮肤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

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

原创 LintCode 1908: Boolean expression evaluation (栈好题)

LintCode 1908: Boolean expression evaluation (栈好题)断"and"和"or“前后是不是"true"和"false"即可。解法2:这题应该也可以用递归解,先找出优先级最低的那个符号,然后左右递归求值。

2022-10-26 16:00:48 228

原创 LintCode 369: Convert Expression to Polish Notation (中序表达式转前序波兰表达式)

LintCode 369: Convert Expression to Polish Notation (中序表达式转前序波兰表达式)

2022-10-26 13:44:56 180

原创 LintCode 424: Evaluate Reverse Polish Notation 递归和栈好题

LintCode 424 · Evaluate Reverse Polish Notation

2022-10-23 10:41:10 385

原创 LeetCode 692: Top K Frequent Words (最小堆好题)

LeetCode 692: 最小堆好题

2022-10-19 09:08:46 119

原创 LintCode 1246: Longest Repeating Character Replacement (同向双指针好题)

LintCode 246: 同向双指针

2022-10-16 12:23:40 336

原创 LintCode 816: Traveling Salesman Problem (著名的旅行商游历NP问题。状态压缩DP经典)

816.Traveling Salesman ProblemGivencities(labeled from1ton), and the undirected road'scostamong the cities as a three-tuple[A, B, c](i.e there is a road between cityAand cityBand the cost isc). We need to find the smallest cost to travel al...

2020-08-14 13:58:26 937

原创 LintCode 740: Coin Change 2 (DP 完全背包类似题)

740.Coin Change 2中文EnglishYou are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin..

2020-08-05 15:58:42 197

原创 LIntCode 1444: Dyeing Problem (DP 好题)

1444.DyeingProblemThereisacircle,dividedintonsectors.Allthesectorsarecoloredwithsomeofmcolors.Thecolorsofadjacentsectorscannotbethesame.Findthetotalnumberofplans.ExampleExample1:Input:n=2,m=3Output:...

2020-08-02 01:49:53 207

原创 LintCode 1329: Sequence maintenance (线段树和树状数组区间更新和区间查询,经典难题!!!)

1329.Sequence maintenanceThere is a sequenceaof lengthn, and there areqoperations on the sequence.Each operation has a queried numberbi, subtracting one from all numbers that greater than or equal tobiin the sequence.Returns how many numbers ar...

2020-07-15 16:25:31 259

原创 LintCode 1295: Prime Factor Statistics (质因数分解经典题)

1295.PrimeFactorStatisticsGivenapositiveintegerN,youneedtofactorizeallintegersbetween(1,N].Thenyouhavetocountthenumberofthetotalprimenumbers.Exampleinput:6output:7explain:2=2,3=3,4=2*2,5=5,6=2*3,thenumber...

2020-07-14 17:19:36 607

原创 LintCode 1529: Triplet Subarray With Absolute Diff Less Than or Equal to Limit (同向双指针经典题)

1529.Triplet Subarray With Absolute Diff Less Than or Equal to LimitGiven an increasingarray of integersnumsand anintegerlimit, return the number of the triplet subarray in which the absolute difference between any two elements is less than or equa...

2020-06-30 16:03:09 3837

原创 LintCode 1852: Final Discounted Price (单调栈经典题)

1852.Final Discounted PriceA shopkeeper has a sale to complete and has arranged the items being sold in an array. Starting from the left, the shopkeeper rings up each item at its full price less the price of the first lower or equal priced item to its r.

2020-06-29 06:10:06 445

原创 LintCode 261: Maximum Connected Area (并查集/BFS好题)

261.MaximumConnectedAreaDescriptionThereisatwo-dimensionalarray,onlyconsistsof00and11.Youcanchangea00to11atmostonce,pleasecalculatethemaximumareaofconnected1s1s.Iftwo1s1sareadjcentuptodownorlefttoright,they...

2020-06-27 13:41:00 476

原创 LintCode 253: Minimum Type Way (双序列DP好题)

253.Minimum Type WayYou are given a string only contains lower or upper English characters that you want to type.At the beginning, the Capslock is off, it's at a state of lower characters, you are required that after typing it should still be at lower .

2020-06-13 15:45:46 295

原创 LintCode 1828: Lake Escape (双状态BFS好题)

1828.Lake EscapeDescriptionAlbert is stranded on a frozen lake. He wants to know if he can make it back to shore. He is currently on a snowbank that gives him some traction, but once he steps the ice. he will slide in the same direction until he hits .

2020-06-07 15:10:50 437

原创 LintCode 1293: Count of Range Sum

1293.Count of Range SumGiven an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), inclusive.ExampleExample 1:.

2020-06-05 11:47:53 188

原创 LintCode 1346: Dungeon Game (DP好题)

Description中文EnglishThe demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knig...

2020-05-06 16:18:23 227

原创 LintCode 450: Reverse Nodes in k-Group (链表翻转题)

450.Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in t...

2020-04-28 15:33:15 170 1

原创 LintCode 722: Maximum Subarray VI (Trie, 异或经典难题)

722.Maximum Subarray VIGiven an array of integers. find the maximum XOR subarray value in given array.What's the XOR:https://en.wikipedia.org/wiki/Exclusive_orExampleExample 1Input: [1, 2...

2020-04-28 13:39:03 388

原创 Lintcode 516: Paint House II (DP好题)

516.Paint House IIThere are a row ofnhouses, each house can be painted with one of thekcolors. The cost of painting each house with a certain color is different. You have to paint all the house...

2020-04-25 14:04:44 317

原创 LintCode 1395: The Barycentre Of The Trees (树的重心-树上的DP题)

The Barycentre Of The TreesFor a multi-branch tree, if there is a node R with R as the root, and the largest sub-tree of all its sub-trees has the least number of nodes, the node R is said to be th...

2020-04-21 23:07:51 388

原创 LintCode 582: Word Break II

Word Break IIGiven a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.ExampleExample...

2020-02-18 12:48:54 223 1

原创 LintCode 805: Maximum Association Set (并查集和BFS好题)

Maximum Association SetAmazon sells books, every book has books which are strongly associated with it. Given ListA and ListB,indicates that ListA [i] is associated with ListB [i] which represents t...

2020-02-16 09:23:45 365

原创 LintCode 630: Knight Shortest Path II (BFS和DP经典题)

Knight Shortest Path IIGiven a knight in a chessboard n * m (a binary matrix with 0 as empty and 1 as barrier). the knight initialze position is (0, 0) and he wants to reach position (n - 1, m - 1)...

2020-02-16 07:11:40 885

原创 LintCode 1235 (LeetCode 449): Serialize and Deserialize BST (二叉树经典题)

Serialize and Deserialize BSTSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across...

2020-02-12 16:45:10 295 1

原创 LintCode 726: Check Full Binary Tree

Check Full Binary TreeA full binary tree is defined as a binary tree in which all nodes have either zero or two child nodes. Conversely, there is no node in a full binary tree, which has one child ...

2020-02-10 07:11:38 178

原创 LintCode 1037: Global and Local Inversions (逆序数经典题)

Global and Local InversionsGiven a permutation A of [0, 1, …, N - 1], where N is the length of A.The number of global inversions is the number of i < j with 0 <= i < j < N and A[i] &gt...

2020-02-06 15:38:48 261 2

原创 LintCode 56: Two Sum (未排序Two Sum, 双指针或hashmap)

Two SumGiven an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the targ...

2020-01-19 10:07:46 261

原创 LintCode 32: Minimum Window Substring (同向双指针好题)

Minimum Window SubstringGiven two strings source and target. Return the minimum substring of source which contains each char of target.ExampleExample 1:Input: source = “abc”, target = ...

2019-11-10 14:12:53 239 1

原创 LintCode 543: Kth Largest in N Arrays (maxHeap经典题)

Kth Largest in N Arrays中文EnglishFind K-th largest element in N arrays.ExampleExample 1:Input:k=3, [[9,3,2,4,7],[1,2,3,4,8]]Output:7Explanation:the 3rd largest element is 7Example 2:Input...

2019-11-10 13:35:47 187

原创 LintCode 92: Backpack (经典背包DP题)

Backpack中文EnglishGiven n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack?ExampleExample 1:Input: [3,4,8,5], backpack size=10Output: 9Exa...

2019-11-10 13:31:22 673 1

原创 LintCode 946: 233 Matrix (矩阵快速幂经典题)

233 Matrix中文EnglishGiven a matric A. The first row of matrix A is 0, 233, 2333, 23333…(i.e., A(0,0)=0,A(0,1)=233,A(0,2)=2333,A(0,3)=23333…). Besides, A(i,j)=A(i-1,j)+A(i,j-1).Given an array X wit...

2019-09-15 14:41:54 311

原创 LintCode 532: Reverse Pairs (树状数组,Merge Sort经典题)

Reverse Pairs中文EnglishReverse pair is a pair of numbers (A[i], A[j]) such that A[i] > A[j] and i < j. Given an array, return the number of reverse pairs in the array.ExampleExample1Input:...

2019-08-22 15:08:19 385

原创 LintCode 841: String Replace (字符串替换好题)

String Replace中文EnglishGiven two identical-sized string array A, B and a string S. All substrings A appearing in S are replaced by B.(Notice: From left to right, it must be replaced if it can be re...

2019-05-19 02:50:53 929 2

原创 LintCode 634: Word Square (搜索经典题!!!)

Word Squares中文EnglishGiven a set of words without duplicates, find all word squares you can build from them.A sequence of words forms a valid word square if the kth row and column read the exact ...

2019-05-17 16:07:25 507

原创 LintCode 652: Factorization (DFS 搜索经典题)

Factorization中文EnglishA non-negative numbers can be regarded as product of its factors.Write a function that takes an integer n and return all possible combinations of its factors.ExampleExampl...

2019-05-05 23:57:51 490

原创 LintCode 915. Inorder Predecessor in BST

Inorder Predecessor in BST中文EnglishGiven a binary search tree and a node in it, find the in-order predecessor of that node in the BST.ExampleExample1Input: root = {2,1,3}, p = 1Output: nullEx...

2019-05-03 15:00:34 525 2

原创 LintCode 155: Minimum Depth of Binary Tree

Minimum Depth of Binary Tree中文EnglishGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node....

2019-05-03 14:14:04 124

原创 LintCode 701. Trim a Binary Search Tree (删减BST树)

Trim a Binary Search Tree中文EnglishGiven the root of a binary search tree and 2 numbers min and max, trim the tree such that all the numbers in the new tree are between min and max (inclusive). The ...

2019-04-28 07:20:24 169

原创 LintCode 463: Sort Integers (QuickSort和MergeSort 经典模板!!!)

Sort Integers中文EnglishGiven 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:...

2019-04-18 15:30:18 1592 1

空空如也

空空如也

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

TA关注的人

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