![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 67
_TCgogogo_
这个作者很懒,什么都没留下…
展开
-
LeetCode 992 Subarrays with K Different Integers (滑动窗 推荐)
题目分析:恰好有k个不好求,但至多有k个则非常容易,恰好k个=至多k个-至多k-1个,至多有k个可以用滑动窗,用hash判断每个数字出现的次数,并用一个值记录当前有多少个不同的数字。题目大意:求恰好有k个不同数字的区间个数。13ms,时间击败88.84%原创 2022-09-07 08:39:54 · 324 阅读 · 0 评论 -
LeetCode 1721 Swapping Nodes in a Linked List (链表 快慢指针)
You are given theheadof a linked list, and an integerk.Returnthe head of the linked list afterswappingthe values of thekthnode from the beginning and thekthnode from the end (the list is1-indexed).Example 1:Input: head = [1,2,3,4,5], k ...原创 2022-05-07 21:24:15 · 358 阅读 · 0 评论 -
LeetCode 402 Remove K Digits (单调栈 贪心 推荐)
Given string num representing a non-negative integernum, and an integerk, returnthe smallest possible integer after removingkdigits fromnum.Example 1:Input: num = "1432219", k = 3Output: "1219"Explanation: Remove the three digits 4, 3, and 2 t...原创 2022-02-04 16:25:08 · 210 阅读 · 0 评论 -
LeetCode 1249 Minimum Remove to Make Valid Parentheses (栈)
Given a stringsof'(',')'and lowercase English characters.Your task is to remove the minimum number of parentheses ('('or')', in any positions ) so that the resultingparentheses stringis valid and returnanyvalid string.Formally, aparenth...原创 2021-12-08 17:01:50 · 86 阅读 · 0 评论 -
LeetCode 1019 Next Greater Node In Linked List (单调栈)
You are given theheadof a linked list withnnodes.For each node in the list, find the value of thenext greater node. That is, for each node, find the value of the first node that is next to it and has astrictly largervalue than it.Return an integ...原创 2021-12-03 16:59:42 · 477 阅读 · 0 评论 -
LeetCode 1171 Remove Zero Sum Consecutive Nodes from Linked List (链表)
Given theheadof a linked list, we repeatedly delete consecutive sequences of nodes that sum to0until there are no such sequences.After doing so, return the head of the final linked list. You may return any such answer.(Note that in the examples be...原创 2021-10-10 16:42:14 · 152 阅读 · 0 评论 -
LeetCode 725 Split Linked List in Parts (分割链表)
Given theheadof a singly linked list and an integerk, split the linked list intokconsecutive linked list parts.The length of each part should be as equal as possible: no two parts should have a size differing by more than one. This may lead to some ...原创 2021-10-10 15:24:26 · 116 阅读 · 0 评论 -
LeetCode 82 Remove Duplicates from Sorted List II (链表)
Given theheadof a sorted linked list,delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Returnthe linked listsortedas well.Example 1:Input: head = [1,2,3,3,4,4,5]Output: [1,2,5]Example 2:...原创 2021-10-10 14:51:20 · 187 阅读 · 0 评论 -
LeetCode 1032 Stream of Characters (Trie 推荐)
Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of stringswords.For example, ifwords = ["abc", "xyz"]and the stream added the four characters (one by one)'a','x','y', a...原创 2021-08-13 13:17:05 · 169 阅读 · 0 评论 -
LeetCode 792 Number of Matching Subsequences (二分或队列)
Given a stringsand an array of stringswords, returnthe number ofwords[i]that is a subsequence ofs.Asubsequenceof a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative...原创 2021-07-04 22:20:03 · 208 阅读 · 0 评论 -
NOJ 2024 入栈序列和出栈序列 (stack)
入栈序列和出栈序列时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:205 测试通过:50描述给出入栈序列{A},保证{A}各个元素值各不相等,输出字典序最大的出栈序列.如入栈序列{A} = 1, 2, 9, 4, 6, 5则字典序最大的出栈序列为9, 6, 5, 4, 2,原创 2014-09-19 08:59:51 · 1158 阅读 · 0 评论 -
POJ 3125 Printer Queue (priority queue)
Printer QueueTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3736 Accepted: 2015DescriptionThe only printer in the computer science students' union is exp原创 2014-09-13 09:27:47 · 994 阅读 · 0 评论 -
codeforces 508E Arthur and Brackets (stack)
E. Arthur and Bracketstime limit per test2 secondsmemory limit per test128 megabytesNotice that the memory limit is non-standard.Recently Arthur and Sasha have studied correct br原创 2015-01-31 14:17:23 · 1453 阅读 · 0 评论 -
HDU 4908 BestCoder Sequence (hash)
BestCoder SequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 660 Accepted Submission(s): 231Problem DescriptionMr Potato原创 2014-08-04 21:50:25 · 871 阅读 · 0 评论 -
NOJ 1098 Rails (stack)
RailsTime Limit(Common/Java):1000MS/3000MS Memory Limit:65536KByteTotal Submit:384 Accepted:117DescriptionThere is a famous railway station in PopPush City. Country the原创 2014-09-30 01:53:53 · 880 阅读 · 0 评论 -
Codeforces Round #275 (Div. 2) D题 (线段树)
D. Interesting Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe'll call an array of n non-negative integersa原创 2014-10-31 02:05:40 · 1162 阅读 · 0 评论 -
HDU 1166 敌兵布阵 (线段树)
敌兵布阵Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 42701 Accepted Submission(s): 18065Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以原创 2014-08-03 11:06:21 · 868 阅读 · 0 评论 -
POJ 1984 Navigation Nightmare (离线并查集)
Navigation NightmareTime Limit: 2000MS Memory Limit: 30000KTotal Submissions: 4599 Accepted: 1734Case Time Limit: 1000MSDescriptionFarmer John's pastoral neighbor原创 2015-02-03 11:59:06 · 2040 阅读 · 2 评论 -
NOJ 1044 连通 OR 不连通 (离线并查集 + hash)
不多的离线并查集原创 2015-02-03 11:57:00 · 1465 阅读 · 0 评论 -
POJ 1330 Nearest Common Ancestors (LCA)
Nearest Common AncestorsTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 19435Accepted: 10294DescriptionA rooted tree is a well-known data structure i原创 2014-12-01 14:59:39 · 803 阅读 · 0 评论 -
HDU 1251 统计难题 (Trie树 模板题)
统计难题Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submission(s): 19874 Accepted Submission(s): 8709Problem Description Ignatius最近遇到一个难题,老师交给他很多原创 2015-02-23 13:47:12 · 940 阅读 · 0 评论 -
POJ 2945 Find the Clones (Trie树 两种姿势)
POJ 2945 Find the Clones (Trie树) 该题详解原创 2015-02-23 11:11:15 · 1222 阅读 · 0 评论 -
HDU 1754 I Hate It (线段树)
I Hate ItTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 37449 Accepted Submission(s): 14817Problem Description很多学校流行一种比较的习惯。老师们很原创 2014-08-03 12:46:23 · 783 阅读 · 0 评论 -
POJ 2503 Babelfish (Trie树 或 map)
POJ 2503 Babelfish (Trie树 或 map)原创 2015-02-24 22:03:55 · 1631 阅读 · 0 评论 -
HDU 2586 How far away ? (离线LCA Tarjan算法模板)
HDU 2586 How far away ? (离线LCA Tarjan算法模板)原创 2015-02-25 22:13:42 · 1262 阅读 · 1 评论 -
POJ 3264 Balanced Lineup (线段树单点更新 区间查询)
POJ 3264 Balanced Lineup (线段树单点更新 区间查询)原创 2015-02-25 00:43:36 · 1280 阅读 · 0 评论 -
POJ 2513 Colored Sticks (Trie树+并查集+欧拉路)
POJ 2513 Colored Sticks (Trie树+并查集+欧拉路)原创 2015-02-11 00:09:18 · 1940 阅读 · 1 评论 -
HDU 1277 全文检索 (Trie树应用 好题)
HDU 1277 全文检索 (trie树应用 好题)原创 2015-02-23 23:32:08 · 1671 阅读 · 0 评论 -
NOJ 1121 Message Flood (Trie树 或者 map)
NOJ 1121 Message Flood (Trie树 或者 map)原创 2015-02-23 20:22:46 · 996 阅读 · 0 评论 -
POJ 2001 Shortest Prefixes (Trie树应用 好题)
POJ 2001 Shortest Prefixes (Trie树应用 好题)原创 2015-02-24 23:34:57 · 1188 阅读 · 0 评论 -
HDU 4041 Eliminate Witches! (栈的模拟)
HDU 4041 Eliminate Witches! (栈的模拟)原创 2015-03-10 13:11:46 · 963 阅读 · 0 评论 -
POJ 3295 Tautology (栈模拟)
POJ 3295 Tautology (栈模拟)原创 2015-03-21 17:08:49 · 984 阅读 · 0 评论 -
HDU 1671 && POJ 3630 Phone List (Trie树 好题)
HDU 1671 && POJ 3630 Phone List (Trie树 好题)原创 2015-02-23 21:58:14 · 1131 阅读 · 0 评论 -
HDU 4923 Room and Moor (数学+单调栈)
HDU 4923 Room and Moor (数学+单调栈)原创 2015-03-22 12:41:15 · 948 阅读 · 0 评论 -
POJ 2431 Expedition (STL 优先权队列)
POJ 2431 Expedition (STL 优先权队列)原创 2015-04-03 00:13:40 · 1276 阅读 · 0 评论 -
POJ 3253 Fence Repair (优先权队列+贪心)
POJ 3253 Fence Repair (优先权队列+贪心)原创 2015-04-03 16:05:48 · 905 阅读 · 0 评论 -
NOJ 机器狗组装费用 (优先权队列)
NOJ 机器狗组装费用 (优先权队列)原创 2015-04-15 11:42:19 · 893 阅读 · 0 评论 -
POJ 3368 Frequent values (基础RMQ)
POJ 3368 Frequent values (基础RMQ)原创 2015-07-05 10:41:37 · 1033 阅读 · 0 评论 -
POJ 1318 Word Amalgamation (字符串 STL大水)
POJ 1318 Word Amalgamation (字符串 STL大水)原创 2015-07-04 00:34:26 · 2031 阅读 · 0 评论 -
HDU 2846 Repository (字典树 后缀建树)
HDU 2846 Repository (字典树 后缀建树)原创 2015-07-12 23:57:19 · 1066 阅读 · 0 评论