Skip to content

Commit

Permalink
Question 400 - Day 39
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanger67 committed Jul 6, 2024
1 parent dbe67f1 commit 3b3693c
Show file tree
Hide file tree
Showing 26 changed files with 577 additions and 31 deletions.
8 changes: 6 additions & 2 deletions README.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions markdowns/Questions_By_Code_Length.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Calculations are based on the code files's byte sizes.
| 771 | [Jewels and Stones](<https://leetcode.com/problems/jewels-and-stones>) | Easy | | [solution](<_771. Jewels and Stones.md>) | py, java | Jun 02, 2024 |
| 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 |
| 1122 | [Relative Sort Array](<https://leetcode.com/problems/relative-sort-array>) | Easy | Daily | [solution](<_1122. Relative Sort Array.md>) | py, java | Jun 10, 2024 |
| 567 | [Permutation in String](<https://leetcode.com/problems/permutation-in-string>) | Medium | N150 | [solution](<_567. Permutation in String.md>) | py | Jul 05, 2024 |
| 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 |
| 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 |
| 791 | [Custom Sort String](<https://leetcode.com/problems/custom-sort-string>) | Medium | | [solution](<_791. Custom Sort String.md>) | java | Jun 24, 2024 |
Expand All @@ -120,6 +121,7 @@ Calculations are based on the code files's byte sizes.
| 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 |
| 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 |
| 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 |
| 622 | [Design Circular Queue](<https://leetcode.com/problems/design-circular-queue>) | Medium | | [solution](<_622. Design Circular Queue.md>) | py | Jul 05, 2024 |
| 1 | [Two Sum](<https://leetcode.com/problems/two-sum>) | Easy | N150, B75 | [solution](<_1. Two Sum.md>) | py, java | May 22, 2024 |
| 1268 | [Search Suggestions System](<https://leetcode.com/problems/search-suggestions-system>) | Medium | | [solution](<_1268. Search Suggestions System.md>) | py | Jun 28, 2024 |
| 20 | [Valid Parentheses](<https://leetcode.com/problems/valid-parentheses>) | Easy | N150, B75 | [solution](<_20. Valid Parentheses.md>) | java | May 22, 2024 |
Expand Down Expand Up @@ -236,6 +238,7 @@ Calculations are based on the code files's byte sizes.
| 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 |
| 3174 | bw contest 132 - q1 | Easy | Contest | [solution](<_3174. bw contest 132 - q.md>) | py | Jun 08, 2024 |
| 49 | [Group Anagrams](<https://leetcode.com/problems/group-anagrams>) | Medium | N150, B75 | [solution](<_49. Group Anagrams.md>) | py | Jun 12, 2024 |
| 1472 | [Design Browser History](<https://leetcode.com/problems/design-browser-history>) | Medium | | [solution](<_1472. Design Browser History.md>) | py | Jul 05, 2024 |
| 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 |
| 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 |
| 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 |
Expand Down Expand Up @@ -288,6 +291,7 @@ Calculations are based on the code files's byte sizes.
| 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 |
| 14 | [Longest Common Prefix](<https://leetcode.com/problems/longest-common-prefix>) | Easy | | [solution](<_14. Longest Common Prefix.md>) | java | May 22, 2024 |
| 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 |
| 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 |
| 1002 | [Find Common Characters](<https://leetcode.com/problems/find-common-characters>) | Easy | Daily | [solution](<_1002. Find Common Characters.md>) | py | Jun 04, 2024 |
| 206 | [Reverse Linked List](<https://leetcode.com/problems/reverse-linked-list>) | Easy | N150, B75 | [solution](<_206. Reverse Linked List.md>) | java | Jun 27, 2024 |
| 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 |
Expand Down
4 changes: 4 additions & 0 deletions markdowns/Questions_By_Recent.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Calculations are based on the date of the first solve.

| # | Title | Level | Cats | Solution | Languages | Date Complete |
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:---------------------------------------------------------------------------------------------------|:---------------------------------|:----------------|
| 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 |
| 1472 | [Design Browser History](<https://leetcode.com/problems/design-browser-history>) | Medium | | [solution](<_1472. Design Browser History.md>) | py | Jul 05, 2024 |
| 622 | [Design Circular Queue](<https://leetcode.com/problems/design-circular-queue>) | Medium | | [solution](<_622. Design Circular Queue.md>) | py | Jul 05, 2024 |
| 567 | [Permutation in String](<https://leetcode.com/problems/permutation-in-string>) | Medium | N150 | [solution](<_567. Permutation in String.md>) | py | Jul 05, 2024 |
| 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 |
| 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 |
| 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 |
Expand Down
22 changes: 11 additions & 11 deletions markdowns/Topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

------

- [Array](<by_topic/Array.md>) (178 completed)
- [Hash Table](<by_topic/Hash Table.md>) (88 completed)
- [String](<by_topic/String.md>) (87 completed)
- [Array](<by_topic/Array.md>) (181 completed)
- [Hash Table](<by_topic/Hash Table.md>) (89 completed)
- [String](<by_topic/String.md>) (88 completed)
- [Depth-First Search](<by_topic/Depth-First Search.md>) (68 completed)
- [Tree](<by_topic/Tree.md>) (66 completed)
- [Binary Tree](<by_topic/Binary Tree.md>) (61 completed)
- [Sorting](<by_topic/Sorting.md>) (55 completed)
- [Math](<by_topic/Math.md>) (49 completed)
- [Breadth-First Search](<by_topic/Breadth-First Search.md>) (47 completed)
- [Two Pointers](<by_topic/Two Pointers.md>) (43 completed)
- [Linked List](<by_topic/Linked List.md>) (38 completed)
- [Stack](<by_topic/Stack.md>) (35 completed)
- [Two Pointers](<by_topic/Two Pointers.md>) (44 completed)
- [Linked List](<by_topic/Linked List.md>) (40 completed)
- [Stack](<by_topic/Stack.md>) (37 completed)
- [Greedy](<by_topic/Greedy.md>) (31 completed)
- [Matrix](<by_topic/Matrix.md>) (30 completed)
- [Simulation](<by_topic/Simulation.md>) (26 completed)
- [Design](<by_topic/Design.md>) (25 completed)
- [Bit Manipulation](<by_topic/Bit Manipulation.md>) (24 completed)
- [Design](<by_topic/Design.md>) (22 completed)
- [Dynamic Programming](<by_topic/Dynamic Programming.md>) (20 completed)
- [Database](<by_topic/Database.md>) (18 completed)
- [Binary Search](<by_topic/Binary Search.md>) (18 completed)
Expand All @@ -30,10 +30,10 @@
- [Recursion](<by_topic/Recursion.md>) (14 completed)
- [Backtracking](<by_topic/Backtracking.md>) (13 completed)
- [Binary Search Tree](<by_topic/Binary Search Tree.md>) (13 completed)
- [Sliding Window](<by_topic/Sliding Window.md>) (11 completed)
- [Sliding Window](<by_topic/Sliding Window.md>) (12 completed)
- [Prefix Sum](<by_topic/Prefix Sum.md>) (10 completed)
- [Queue](<by_topic/Queue.md>) (9 completed)
- [Monotonic Stack](<by_topic/Monotonic Stack.md>) (9 completed)
- [Queue](<by_topic/Queue.md>) (8 completed)
- [Union Find](<by_topic/Union Find.md>) (8 completed)
- [Divide and Conquer](<by_topic/Divide and Conquer.md>) (6 completed)
- [String Matching](<by_topic/String Matching.md>) (6 completed)
Expand All @@ -42,6 +42,7 @@
- [Combinatorics](<by_topic/Combinatorics.md>) (4 completed)
- [Randomized](<by_topic/Randomized.md>) (4 completed)
- [Monotonic Queue](<by_topic/Monotonic Queue.md>) (3 completed)
- [Doubly-Linked List](<by_topic/Doubly-Linked List.md>) (3 completed)
- [Iterator](<by_topic/Iterator.md>) (3 completed)
- [Bucket Sort](<by_topic/Bucket Sort.md>) (3 completed)
- [Geometry](<by_topic/Geometry.md>) (2 completed)
Expand All @@ -50,10 +51,9 @@
- [Game Theory](<by_topic/Game Theory.md>) (2 completed)
- [Interactive](<by_topic/Interactive.md>) (2 completed)
- [Memoization](<by_topic/Memoization.md>) (2 completed)
- [Data Stream](<by_topic/Data Stream.md>) (2 completed)
- [Rolling Hash](<by_topic/Rolling Hash.md>) (2 completed)
- [Quickselect](<by_topic/Quickselect.md>) (2 completed)
- [Doubly-Linked List](<by_topic/Doubly-Linked List.md>) (2 completed)
- [Data Stream](<by_topic/Data Stream.md>) (1 completed)
- [Bitmask](<by_topic/Bitmask.md>) (1 completed)
- [Merge Sort](<by_topic/Merge Sort.md>) (1 completed)
- [Ordered Set](<by_topic/Ordered Set.md>) (1 completed)
Expand Down
62 changes: 62 additions & 0 deletions markdowns/_1381. Design a Stack With Increment Operation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 1381. [Design a Stack With Increment Operation](<https://leetcode.com/problems/design-a-stack-with-increment-operation>)

*[Back to top](<../README.md>)*

------

> *First completed : July 05, 2024*
>
> *Last updated : July 05, 2024*

------

> **Related Topics** : **[Array](<by_topic/Array.md>), [Stack](<by_topic/Stack.md>), [Design](<by_topic/Design.md>)**
>
> **Acceptance Rate** : **77.091 %**

------

*To see the question prompt, click the title.*

> ## This question has the honour of being my 400th question on LeetCode.
>
> **On Day 39 of my grind, 8:35PM PST, this question was done. Simple one to end off this sprint. :)**
------

## Solutions

- [m1381.py](<../my-submissions/m1381.py>)
### Python
#### [m1381.py](<../my-submissions/m1381.py>)
```Python
class CustomStack:

def __init__(self, maxSize: int):
self.stk = []
self.maxx = maxSize

def push(self, x: int) -> None:
if len(self.stk) >= self.maxx :
return
self.stk.append(x)

def pop(self) -> int:
if not self.stk :
return -1
return self.stk.pop()

def increment(self, k: int, val: int) -> None:
for i in range(min(k, len(self.stk))) :
self.stk[i] += val


# Your CustomStack object will be instantiated and called as such:
# obj = CustomStack(maxSize)
# obj.push(x)
# param_2 = obj.pop()
# obj.increment(k,val)
```

Loading

0 comments on commit 3b3693c

Please sign in to comment.