Skip to content

Commit

Permalink
Updated markdown files
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanger67/leetcode authored and Zanger67/leetcode committed Aug 2, 2024
1 parent 1063e46 commit 348b52f
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (482 solved)
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (483 solved)

<!-- This readme was generated using [WikiLeet](<https://github.com/Zanger67/WikiLeet>) -->

Expand Down Expand Up @@ -417,6 +417,7 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
| 2095 | [Delete the Middle Node of a Linked List](<https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list>) | Medium | | [solution](<markdowns/_2095. Delete the Middle Node of a Linked List.md>) | c, java |
| 2096 | [Step-By-Step Directions From a Binary Tree Node to Another](<https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another>) | Medium | Daily | [solution](<markdowns/_2096. Step-By-Step Directions From a Binary Tree Node to Another.md>) | py |
| 2130 | [Maximum Twin Sum of a Linked List](<https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list>) | Medium | | [solution](<markdowns/_2130. Maximum Twin Sum of a Linked List.md>) | py |
| 2134 | [Minimum Swaps to Group All 1's Together II](<https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii>) | Medium | Daily | [solution](<markdowns/_2134. Minimum Swaps to Group All 1's Together II.md>) | py |
| 2149 | [Rearrange Array Elements by Sign](<https://leetcode.com/problems/rearrange-array-elements-by-sign>) | Medium | | [solution](<markdowns/_2149. Rearrange Array Elements by Sign.md>) | c, py |
| 2165 | [Smallest Value of the Rearranged Number](<https://leetcode.com/problems/smallest-value-of-the-rearranged-number>) | Medium | | [solution](<markdowns/_2165. Smallest Value of the Rearranged Number.md>) | py |
| 2181 | [Merge Nodes in Between Zeros](<https://leetcode.com/problems/merge-nodes-in-between-zeros>) | Medium | Daily | [solution](<markdowns/_2181. Merge Nodes in Between Zeros.md>) | c, cpp, java, py |
Expand Down
1 change: 1 addition & 0 deletions markdowns/Daily_Questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Dates are for the date I completed the question so due to the my time zone and h

| # | Title | Level | Cats | Solution | Languages | Date Complete |
|-----:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:------------|:----------------------------------------------------------------------------------------------------|:-----------------------------|:----------------|
| 2134 | [Minimum Swaps to Group All 1's Together II](<https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii>) | Medium | Daily | [solution](<_2134. Minimum Swaps to Group All 1's Together II.md>) | py | Aug 02, 2024 |
| 2678 | [Number of Senior Citizens](<https://leetcode.com/problems/number-of-senior-citizens>) | Easy | Daily | [solution](<_2678. Number of Senior Citizens.md>) | c, java, py | Aug 01, 2024 |
| 1105 | [Filling Bookcase Shelves](<https://leetcode.com/problems/filling-bookcase-shelves>) | Medium | Daily | [solution](<_1105. Filling Bookcase Shelves.md>) | py | Jul 31, 2024 |
| 1653 | [Minimum Deletions to Make String Balanced](<https://leetcode.com/problems/minimum-deletions-to-make-string-balanced>) | Medium | Daily | [solution](<_1653. Minimum Deletions to Make String Balanced.md>) | py | Jul 30, 2024 |
Expand Down
3 changes: 2 additions & 1 deletion markdowns/Medium.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Medium Questions (310)
# Medium Questions (311)

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

Expand Down Expand Up @@ -255,6 +255,7 @@
| 2095 | [Delete the Middle Node of a Linked List](<https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list>) | Medium | | [solution](<_2095. Delete the Middle Node of a Linked List.md>) | c, java | Jun 07, 2024 |
| 2096 | [Step-By-Step Directions From a Binary Tree Node to Another](<https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another>) | Medium | Daily | [solution](<_2096. Step-By-Step Directions From a Binary Tree Node to Another.md>) | py | Jul 16, 2024 |
| 2130 | [Maximum Twin Sum of a Linked List](<https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list>) | Medium | | [solution](<_2130. Maximum Twin Sum of a Linked List.md>) | py | Jun 21, 2024 |
| 2134 | [Minimum Swaps to Group All 1's Together II](<https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii>) | Medium | Daily | [solution](<_2134. Minimum Swaps to Group All 1's Together II.md>) | py | Aug 02, 2024 |
| 2149 | [Rearrange Array Elements by Sign](<https://leetcode.com/problems/rearrange-array-elements-by-sign>) | Medium | | [solution](<_2149. Rearrange Array Elements by Sign.md>) | c, py | Jun 10, 2024 |
| 2165 | [Smallest Value of the Rearranged Number](<https://leetcode.com/problems/smallest-value-of-the-rearranged-number>) | Medium | | [solution](<_2165. Smallest Value of the Rearranged Number.md>) | py | Jul 01, 2024 |
| 2181 | [Merge Nodes in Between Zeros](<https://leetcode.com/problems/merge-nodes-in-between-zeros>) | Medium | Daily | [solution](<_2181. Merge Nodes in Between Zeros.md>) | c, cpp, java, py | Jul 04, 2024 |
Expand Down
1 change: 1 addition & 0 deletions markdowns/Questions_By_Code_Length.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ Calculations are based on the code files's byte sizes.
| 1249 | [Minimum Remove to Make Valid Parentheses](<https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses>) | Medium | | [solution](<_1249. Minimum Remove to Make Valid Parentheses.md>) | py | Jun 10, 2024 |
| 853 | [Car Fleet](<https://leetcode.com/problems/car-fleet>) | Medium | N150 | [solution](<_853. Car Fleet.md>) | py | Jun 14, 2024 |
| 74 | [Search a 2D Matrix](<https://leetcode.com/problems/search-a-2d-matrix>) | Medium | N150 | [solution](<_74. Search a 2D Matrix.md>) | py | Jun 15, 2024 |
| 2134 | [Minimum Swaps to Group All 1's Together II](<https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii>) | Medium | Daily | [solution](<_2134. Minimum Swaps to Group All 1's Together II.md>) | py | Aug 02, 2024 |
| 1161 | [Maximum Level Sum of a Binary Tree](<https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree>) | Medium | | [solution](<_1161. Maximum Level Sum of a Binary Tree.md>) | py | Jul 17, 2024 |
| 1052 | [Grumpy Bookstore Owner](<https://leetcode.com/problems/grumpy-bookstore-owner>) | Medium | | [solution](<_1052. Grumpy Bookstore Owner.md>) | py | Jun 24, 2024 |
| 540 | [Single Element in a Sorted Array](<https://leetcode.com/problems/single-element-in-a-sorted-array>) | Medium | | [solution](<_540. Single Element in a Sorted Array.md>) | py | Jul 05, 2024 |
Expand Down
1 change: 1 addition & 0 deletions markdowns/Questions_By_Recent.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Calculations are based on the date of the first solve.

| # | Title | Level | Cats | Solution | Languages | Date Complete |
|-----:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:----------------------------------------------------------------------------------------------------|:--------------------------------------------|:----------------|
| 2134 | [Minimum Swaps to Group All 1's Together II](<https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii>) | Medium | Daily | [solution](<_2134. Minimum Swaps to Group All 1's Together II.md>) | py | Aug 02, 2024 |
| 1062 | [Longest Repeating Substring](<https://leetcode.com/problems/longest-repeating-substring>) | Medium | Weekly Premium | [solution](<_1062. Longest Repeating Substring.md>) | py | Aug 01, 2024 |
| 653 | [Two Sum IV - Input is a BST](<https://leetcode.com/problems/two-sum-iv-input-is-a-bst>) | Easy | | [solution](<_653. Two Sum IV - Input is a BST.md>) | py | Jul 31, 2024 |
| 170 | [Two Sum III - Data structure design](<https://leetcode.com/problems/two-sum-iii-data-structure-design>) | Easy | | [solution](<_170. Two Sum III - Data structure design.md>) | py | Jul 31, 2024 |
Expand Down
4 changes: 2 additions & 2 deletions markdowns/Topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

------

- [Array](<by_topic/Array.md>) (220 completed)
- [Array](<by_topic/Array.md>) (221 completed)
- [String](<by_topic/String.md>) (108 completed)
- [Hash Table](<by_topic/Hash Table.md>) (105 completed)
- [Tree](<by_topic/Tree.md>) (78 completed)
Expand All @@ -30,7 +30,7 @@
- [Recursion](<by_topic/Recursion.md>) (17 completed)
- [Backtracking](<by_topic/Backtracking.md>) (16 completed)
- [Binary Search Tree](<by_topic/Binary Search Tree.md>) (16 completed)
- [Sliding Window](<by_topic/Sliding Window.md>) (13 completed)
- [Sliding Window](<by_topic/Sliding Window.md>) (14 completed)
- [Graph](<by_topic/Graph.md>) (12 completed)
- [Prefix Sum](<by_topic/Prefix Sum.md>) (12 completed)
- [Queue](<by_topic/Queue.md>) (11 completed)
Expand Down
53 changes: 53 additions & 0 deletions markdowns/_2134. Minimum Swaps to Group All 1's Together II.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 2134. [Minimum Swaps to Group All 1's Together II](<https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii>)

*All prompts are owned by LeetCode. To view the prompt, click the title link above.*

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

------

> *First completed : August 02, 2024*
>
> *Last updated : August 02, 2024*
------

> **Related Topics** : **[Array](<by_topic/Array.md>), [Sliding Window](<by_topic/Sliding Window.md>)**
>
> **Acceptance Rate** : **52.72 %**
------

## Solutions

- [m2134.py](<../my-submissions/m2134.py>)
### Python
#### [m2134.py](<../my-submissions/m2134.py>)
```Python
class Solution:
def minSwaps(self, nums: List[int]) -> int:
totalOnes = nums.count(1)
if not totalOnes :
return 0

oneCount = nums[:totalOnes].count(1)
zeroCount = totalOnes - oneCount
minMoves = zeroCount

for i, nxtVal in enumerate(nums[totalOnes:] + nums[:totalOnes], totalOnes) :
if nxtVal :
oneCount += 1
else :
zeroCount += 1

if nums[i - totalOnes] :
oneCount -= 1
else :
zeroCount -= 1

minMoves = min(minMoves, zeroCount)

return minMoves
git p
```

3 changes: 2 additions & 1 deletion markdowns/by_topic/Array.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Array](<https://leetcode.com/tag/Array/>) (220 completed)
# [Array](<https://leetcode.com/tag/Array/>) (221 completed)

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

Expand Down Expand Up @@ -175,6 +175,7 @@
| 2011 | [Final Value of Variable After Performing Operations](<https://leetcode.com/problems/final-value-of-variable-after-performing-operations>) | Easy | | [solution](<../_2011. Final Value of Variable After Performing Operations.md>) | c | Jun 03, 2024 |
| 2013 | [Detect Squares](<https://leetcode.com/problems/detect-squares>) | Medium | N150 | [solution](<../_2013. Detect Squares.md>) | py | Jun 28, 2024 |
| 2037 | [Minimum Number of Moves to Seat Everyone](<https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone>) | Easy | Daily | [solution](<../_2037. Minimum Number of Moves to Seat Everyone.md>) | c, py | Jun 03, 2024 |
| 2134 | [Minimum Swaps to Group All 1's Together II](<https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii>) | Medium | Daily | [solution](<../_2134. Minimum Swaps to Group All 1's Together II.md>) | py | Aug 02, 2024 |
| 2149 | [Rearrange Array Elements by Sign](<https://leetcode.com/problems/rearrange-array-elements-by-sign>) | Medium | | [solution](<../_2149. Rearrange Array Elements by Sign.md>) | c, py | Jun 10, 2024 |
| 2191 | [Sort the Jumbled Numbers](<https://leetcode.com/problems/sort-the-jumbled-numbers>) | Medium | Daily | [solution](<../_2191. Sort the Jumbled Numbers.md>) | py | Jul 24, 2024 |
| 2196 | [Create Binary Tree From Descriptions](<https://leetcode.com/problems/create-binary-tree-from-descriptions>) | Medium | Daily | [solution](<../_2196. Create Binary Tree From Descriptions.md>) | py | Jul 15, 2024 |
Expand Down
Loading

0 comments on commit 348b52f

Please sign in to comment.