Skip to content

Commit 3b3693c

Browse files
committed
Question 400 - Day 39
1 parent dbe67f1 commit 3b3693c

26 files changed

+577
-31
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Large diffs are not rendered by default.

markdowns/Questions_By_Code_Length.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Calculations are based on the code files's byte sizes.
108108
| 771 | [Jewels and Stones](<https://leetcode.com/problems/jewels-and-stones>) | Easy | | [solution](<_771. Jewels and Stones.md>) | py, java | Jun 02, 2024 |
109109
| 863 | [All Nodes Distance K in Binary Tree](<https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree>) | Medium | | [solution](<_863. All Nodes Distance K in Binary Tree.md>) | py | Jun 26, 2024 |
110110
| 1122 | [Relative Sort Array](<https://leetcode.com/problems/relative-sort-array>) | Easy | Daily | [solution](<_1122. Relative Sort Array.md>) | py, java | Jun 10, 2024 |
111+
| 567 | [Permutation in String](<https://leetcode.com/problems/permutation-in-string>) | Medium | N150 | [solution](<_567. Permutation in String.md>) | py | Jul 05, 2024 |
111112
| 1209 | [Remove All Adjacent Duplicates in String II](<https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii>) | Medium | | [solution](<_1209. Remove All Adjacent Duplicates in String II.md>) | py | Jun 17, 2024 |
112113
| 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](<https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list>) | Medium | | [solution](<_1171. Remove Zero Sum Consecutive Nodes from Linked List.md>) | py | Jun 15, 2024 |
113114
| 791 | [Custom Sort String](<https://leetcode.com/problems/custom-sort-string>) | Medium | | [solution](<_791. Custom Sort String.md>) | java | Jun 24, 2024 |
@@ -120,6 +121,7 @@ Calculations are based on the code files's byte sizes.
120121
| 919 | [Complete Binary Tree Inserter](<https://leetcode.com/problems/complete-binary-tree-inserter>) | Medium | | [solution](<_919. Complete Binary Tree Inserter.md>) | py | Jul 05, 2024 |
121122
| 271 | [Encode and Decode Strings](<https://leetcode.com/problems/encode-and-decode-strings>) | Medium | N150, B75 | [solution](<_271. Encode and Decode Strings.md>) | py | Jun 12, 2024 |
122123
| 24 | [Swap Nodes in Pairs](<https://leetcode.com/problems/swap-nodes-in-pairs>) | Medium | | [solution](<_24. Swap Nodes in Pairs.md>) | c | Jun 06, 2024 |
124+
| 622 | [Design Circular Queue](<https://leetcode.com/problems/design-circular-queue>) | Medium | | [solution](<_622. Design Circular Queue.md>) | py | Jul 05, 2024 |
123125
| 1 | [Two Sum](<https://leetcode.com/problems/two-sum>) | Easy | N150, B75 | [solution](<_1. Two Sum.md>) | py, java | May 22, 2024 |
124126
| 1268 | [Search Suggestions System](<https://leetcode.com/problems/search-suggestions-system>) | Medium | | [solution](<_1268. Search Suggestions System.md>) | py | Jun 28, 2024 |
125127
| 20 | [Valid Parentheses](<https://leetcode.com/problems/valid-parentheses>) | Easy | N150, B75 | [solution](<_20. Valid Parentheses.md>) | java | May 22, 2024 |
@@ -236,6 +238,7 @@ Calculations are based on the code files's byte sizes.
236238
| 807 | [Max Increase to Keep City Skyline](<https://leetcode.com/problems/max-increase-to-keep-city-skyline>) | Medium | | [solution](<_807. Max Increase to Keep City Skyline.md>) | java | Jun 22, 2024 |
237239
| 3174 | bw contest 132 - q1 | Easy | Contest | [solution](<_3174. bw contest 132 - q.md>) | py | Jun 08, 2024 |
238240
| 49 | [Group Anagrams](<https://leetcode.com/problems/group-anagrams>) | Medium | N150, B75 | [solution](<_49. Group Anagrams.md>) | py | Jun 12, 2024 |
241+
| 1472 | [Design Browser History](<https://leetcode.com/problems/design-browser-history>) | Medium | | [solution](<_1472. Design Browser History.md>) | py | Jul 05, 2024 |
239242
| 720 | [Longest Word in Dictionary](<https://leetcode.com/problems/longest-word-in-dictionary>) | Medium | | [solution](<_720. Longest Word in Dictionary.md>) | py | Jun 27, 2024 |
240243
| 1858 | [Longest Word With All Prefixes](<https://leetcode.com/problems/longest-word-with-all-prefixes>) | Medium | | [solution](<_1858. Longest Word With All Prefixes.md>) | py | Jun 29, 2024 |
241244
| 1455 | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](<https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence>) | Easy | | [solution](<_1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence.md>) | py | Jun 01, 2024 |
@@ -288,6 +291,7 @@ Calculations are based on the code files's byte sizes.
288291
| 1669 | [Merge In Between Linked Lists](<https://leetcode.com/problems/merge-in-between-linked-lists>) | Medium | | [solution](<_1669. Merge In Between Linked Lists.md>) | c | Jun 24, 2024 |
289292
| 14 | [Longest Common Prefix](<https://leetcode.com/problems/longest-common-prefix>) | Easy | | [solution](<_14. Longest Common Prefix.md>) | java | May 22, 2024 |
290293
| 3043 | [Find the Length of the Longest Common Prefix](<https://leetcode.com/problems/find-the-length-of-the-longest-common-prefix>) | Medium | | [solution](<_3043. Find the Length of the Longest Common Prefix.md>) | py | Jun 27, 2024 |
294+
| 1381 | [Design a Stack With Increment Operation](<https://leetcode.com/problems/design-a-stack-with-increment-operation>) | Medium | | [solution](<_1381. Design a Stack With Increment Operation.md>) | py | Jul 05, 2024 |
291295
| 1002 | [Find Common Characters](<https://leetcode.com/problems/find-common-characters>) | Easy | Daily | [solution](<_1002. Find Common Characters.md>) | py | Jun 04, 2024 |
292296
| 206 | [Reverse Linked List](<https://leetcode.com/problems/reverse-linked-list>) | Easy | N150, B75 | [solution](<_206. Reverse Linked List.md>) | java | Jun 27, 2024 |
293297
| 2083 | [Substrings That Begin and End With the Same Letter](<https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter>) | Medium | Weekly Premium | [solution](<_2083. Substrings That Begin and End With the Same Letter.md>) | py, c | Jun 10, 2024 |

markdowns/Questions_By_Recent.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Calculations are based on the date of the first solve.
66

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:---------------------------------------------------------------------------------------------------|:---------------------------------|:----------------|
9+
| 1381 | [Design a Stack With Increment Operation](<https://leetcode.com/problems/design-a-stack-with-increment-operation>) | Medium | | [solution](<_1381. Design a Stack With Increment Operation.md>) | py | Jul 05, 2024 |
10+
| 1472 | [Design Browser History](<https://leetcode.com/problems/design-browser-history>) | Medium | | [solution](<_1472. Design Browser History.md>) | py | Jul 05, 2024 |
11+
| 622 | [Design Circular Queue](<https://leetcode.com/problems/design-circular-queue>) | Medium | | [solution](<_622. Design Circular Queue.md>) | py | Jul 05, 2024 |
12+
| 567 | [Permutation in String](<https://leetcode.com/problems/permutation-in-string>) | Medium | N150 | [solution](<_567. Permutation in String.md>) | py | Jul 05, 2024 |
913
| 380 | [Insert Delete GetRandom O(1)](<https://leetcode.com/problems/insert-delete-getrandom-o1>) | Medium | | [solution](<_380. Insert Delete GetRandom O(1).md>) | java | Jul 05, 2024 |
1014
| 381 | [Insert Delete GetRandom O(1) - Duplicates allowed](<https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed>) | Hard | | [solution](<_381. Insert Delete GetRandom O(1) - Duplicates allowed.md>) | java | Jul 05, 2024 |
1115
| 2582 | [Pass the Pillow](<https://leetcode.com/problems/pass-the-pillow>) | Easy | Daily | [solution](<_2582. Pass the Pillow.md>) | py, java, cs, js, cpp, c | Jul 05, 2024 |

markdowns/Topics.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
------
66

7-
- [Array](<by_topic/Array.md>) (178 completed)
8-
- [Hash Table](<by_topic/Hash Table.md>) (88 completed)
9-
- [String](<by_topic/String.md>) (87 completed)
7+
- [Array](<by_topic/Array.md>) (181 completed)
8+
- [Hash Table](<by_topic/Hash Table.md>) (89 completed)
9+
- [String](<by_topic/String.md>) (88 completed)
1010
- [Depth-First Search](<by_topic/Depth-First Search.md>) (68 completed)
1111
- [Tree](<by_topic/Tree.md>) (66 completed)
1212
- [Binary Tree](<by_topic/Binary Tree.md>) (61 completed)
1313
- [Sorting](<by_topic/Sorting.md>) (55 completed)
1414
- [Math](<by_topic/Math.md>) (49 completed)
1515
- [Breadth-First Search](<by_topic/Breadth-First Search.md>) (47 completed)
16-
- [Two Pointers](<by_topic/Two Pointers.md>) (43 completed)
17-
- [Linked List](<by_topic/Linked List.md>) (38 completed)
18-
- [Stack](<by_topic/Stack.md>) (35 completed)
16+
- [Two Pointers](<by_topic/Two Pointers.md>) (44 completed)
17+
- [Linked List](<by_topic/Linked List.md>) (40 completed)
18+
- [Stack](<by_topic/Stack.md>) (37 completed)
1919
- [Greedy](<by_topic/Greedy.md>) (31 completed)
2020
- [Matrix](<by_topic/Matrix.md>) (30 completed)
2121
- [Simulation](<by_topic/Simulation.md>) (26 completed)
22+
- [Design](<by_topic/Design.md>) (25 completed)
2223
- [Bit Manipulation](<by_topic/Bit Manipulation.md>) (24 completed)
23-
- [Design](<by_topic/Design.md>) (22 completed)
2424
- [Dynamic Programming](<by_topic/Dynamic Programming.md>) (20 completed)
2525
- [Database](<by_topic/Database.md>) (18 completed)
2626
- [Binary Search](<by_topic/Binary Search.md>) (18 completed)
@@ -30,10 +30,10 @@
3030
- [Recursion](<by_topic/Recursion.md>) (14 completed)
3131
- [Backtracking](<by_topic/Backtracking.md>) (13 completed)
3232
- [Binary Search Tree](<by_topic/Binary Search Tree.md>) (13 completed)
33-
- [Sliding Window](<by_topic/Sliding Window.md>) (11 completed)
33+
- [Sliding Window](<by_topic/Sliding Window.md>) (12 completed)
3434
- [Prefix Sum](<by_topic/Prefix Sum.md>) (10 completed)
35+
- [Queue](<by_topic/Queue.md>) (9 completed)
3536
- [Monotonic Stack](<by_topic/Monotonic Stack.md>) (9 completed)
36-
- [Queue](<by_topic/Queue.md>) (8 completed)
3737
- [Union Find](<by_topic/Union Find.md>) (8 completed)
3838
- [Divide and Conquer](<by_topic/Divide and Conquer.md>) (6 completed)
3939
- [String Matching](<by_topic/String Matching.md>) (6 completed)
@@ -42,6 +42,7 @@
4242
- [Combinatorics](<by_topic/Combinatorics.md>) (4 completed)
4343
- [Randomized](<by_topic/Randomized.md>) (4 completed)
4444
- [Monotonic Queue](<by_topic/Monotonic Queue.md>) (3 completed)
45+
- [Doubly-Linked List](<by_topic/Doubly-Linked List.md>) (3 completed)
4546
- [Iterator](<by_topic/Iterator.md>) (3 completed)
4647
- [Bucket Sort](<by_topic/Bucket Sort.md>) (3 completed)
4748
- [Geometry](<by_topic/Geometry.md>) (2 completed)
@@ -50,10 +51,9 @@
5051
- [Game Theory](<by_topic/Game Theory.md>) (2 completed)
5152
- [Interactive](<by_topic/Interactive.md>) (2 completed)
5253
- [Memoization](<by_topic/Memoization.md>) (2 completed)
54+
- [Data Stream](<by_topic/Data Stream.md>) (2 completed)
5355
- [Rolling Hash](<by_topic/Rolling Hash.md>) (2 completed)
5456
- [Quickselect](<by_topic/Quickselect.md>) (2 completed)
55-
- [Doubly-Linked List](<by_topic/Doubly-Linked List.md>) (2 completed)
56-
- [Data Stream](<by_topic/Data Stream.md>) (1 completed)
5757
- [Bitmask](<by_topic/Bitmask.md>) (1 completed)
5858
- [Merge Sort](<by_topic/Merge Sort.md>) (1 completed)
5959
- [Ordered Set](<by_topic/Ordered Set.md>) (1 completed)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# 1381. [Design a Stack With Increment Operation](<https://leetcode.com/problems/design-a-stack-with-increment-operation>)
2+
3+
*[Back to top](<../README.md>)*
4+
5+
------
6+
7+
> *First completed : July 05, 2024*
8+
>
9+
> *Last updated : July 05, 2024*
10+
11+
12+
------
13+
14+
> **Related Topics** : **[Array](<by_topic/Array.md>), [Stack](<by_topic/Stack.md>), [Design](<by_topic/Design.md>)**
15+
>
16+
> **Acceptance Rate** : **77.091 %**
17+
18+
19+
------
20+
21+
*To see the question prompt, click the title.*
22+
23+
> ## This question has the honour of being my 400th question on LeetCode.
24+
>
25+
> **On Day 39 of my grind, 8:35PM PST, this question was done. Simple one to end off this sprint. :)**
26+
27+
------
28+
29+
## Solutions
30+
31+
- [m1381.py](<../my-submissions/m1381.py>)
32+
### Python
33+
#### [m1381.py](<../my-submissions/m1381.py>)
34+
```Python
35+
class CustomStack:
36+
37+
def __init__(self, maxSize: int):
38+
self.stk = []
39+
self.maxx = maxSize
40+
41+
def push(self, x: int) -> None:
42+
if len(self.stk) >= self.maxx :
43+
return
44+
self.stk.append(x)
45+
46+
def pop(self) -> int:
47+
if not self.stk :
48+
return -1
49+
return self.stk.pop()
50+
51+
def increment(self, k: int, val: int) -> None:
52+
for i in range(min(k, len(self.stk))) :
53+
self.stk[i] += val
54+
55+
56+
# Your CustomStack object will be instantiated and called as such:
57+
# obj = CustomStack(maxSize)
58+
# obj.push(x)
59+
# param_2 = obj.pop()
60+
# obj.increment(k,val)
61+
```
62+

0 commit comments

Comments
 (0)