Skip to content

Commit fc9502c

Browse files
committed
Additional JS 30 Days
1 parent 28309f9 commit fc9502c

11 files changed

+264
-1
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (418 solved)
1+
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (421 solved)
22

33
> My LeetCode Profile: [Zanger](https://leetcode.com/u/Zanger/)
44
@@ -407,6 +407,8 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
407407
| 2620 | [Counter](<https://leetcode.com/problems/counter>) | Easy | | [solution](<markdowns/_2620. Counter.md>) | js |
408408
| 2621 | [Sleep](<https://leetcode.com/problems/sleep>) | Easy | | [solution](<markdowns/_2621. Sleep.md>) | js |
409409
| 2623 | [Memoize](<https://leetcode.com/problems/memoize>) | Medium | | [solution](<markdowns/_2623. Memoize.md>) | js |
410+
| 2624 | [Snail Traversal](<https://leetcode.com/problems/snail-traversal>) | Medium | | [solution](<markdowns/_2624. Snail Traversal.md>) | js |
411+
| 2626 | [Array Reduce Transformation](<https://leetcode.com/problems/array-reduce-transformation>) | Easy | | [solution](<markdowns/_2626. Array Reduce Transformation.md>) | js |
410412
| 2629 | [Function Composition](<https://leetcode.com/problems/function-composition>) | Easy | | [solution](<markdowns/_2629. Function Composition.md>) | js |
411413
| 2634 | [Filter Elements from Array](<https://leetcode.com/problems/filter-elements-from-array>) | Easy | | [solution](<markdowns/_2634. Filter Elements from Array.md>) | js |
412414
| 2635 | [Apply Transform Over Each Element in Array](<https://leetcode.com/problems/apply-transform-over-each-element-in-array>) | Easy | | [solution](<markdowns/_2635. Apply Transform Over Each Element in Array.md>) | js |
@@ -418,6 +420,7 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
418420
| 2679 | [Sum in a Matrix](<https://leetcode.com/problems/sum-in-a-matrix>) | Medium | | [solution](<markdowns/_2679. Sum in a Matrix.md>) | java |
419421
| 2703 | [Return Length of Arguments Passed](<https://leetcode.com/problems/return-length-of-arguments-passed>) | Easy | | [solution](<markdowns/_2703. Return Length of Arguments Passed.md>) | js, ts |
420422
| 2704 | [To Be Or Not To Be](<https://leetcode.com/problems/to-be-or-not-to-be>) | Easy | | [solution](<markdowns/_2704. To Be Or Not To Be.md>) | js |
423+
| 2723 | [Add Two Promises](<https://leetcode.com/problems/add-two-promises>) | Easy | | [solution](<markdowns/_2723. Add Two Promises.md>) | js |
421424
| 2734 | [Lexicographically Smallest String After Substring Operation](<https://leetcode.com/problems/lexicographically-smallest-string-after-substring-operation>) | Medium | | [solution](<markdowns/_2734. Lexicographically Smallest String After Substring Operation.md>) | py |
422425
| 2743 | [Count Substrings Without Repeating Character](<https://leetcode.com/problems/count-substrings-without-repeating-character>) | Medium | Weekly Premium | [solution](<markdowns/_2743. Count Substrings Without Repeating Character.md>) | java, py |
423426
| 2807 | [Insert Greatest Common Divisors in Linked List](<https://leetcode.com/problems/insert-greatest-common-divisors-in-linked-list>) | Medium | | [solution](<markdowns/_2807. Insert Greatest Common Divisors in Linked List.md>) | py |

markdowns/Questions_By_Code_Length.md

+3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Calculations are based on the code files's byte sizes.
201201
| 2374 | [Node With Highest Edge Score](<https://leetcode.com/problems/node-with-highest-edge-score>) | Medium | | [solution](<_2374. Node With Highest Edge Score.md>) | py | Jun 17, 2024 |
202202
| 890 | [Find and Replace Pattern](<https://leetcode.com/problems/find-and-replace-pattern>) | Medium | | [solution](<_890. Find and Replace Pattern.md>) | py | Jul 02, 2024 |
203203
| 21 | [Merge Two Sorted Lists](<https://leetcode.com/problems/merge-two-sorted-lists>) | Easy | B75, N150 | [solution](<_21. Merge Two Sorted Lists.md>) | java | May 22, 2024 |
204+
| 2723 | [Add Two Promises](<https://leetcode.com/problems/add-two-promises>) | Easy | | [solution](<_2723. Add Two Promises.md>) | js | Jul 08, 2024 |
204205
| 208 | [Implement Trie (Prefix Tree)](<https://leetcode.com/problems/implement-trie-prefix-tree>) | Medium | B75, N150 | [solution](<_208. Implement Trie (Prefix Tree).md>) | py | Jun 27, 2024 |
205206
| 2679 | [Sum in a Matrix](<https://leetcode.com/problems/sum-in-a-matrix>) | Medium | | [solution](<_2679. Sum in a Matrix.md>) | java | May 22, 2024 |
206207
| 784 | [Letter Case Permutation](<https://leetcode.com/problems/letter-case-permutation>) | Medium | | [solution](<_784. Letter Case Permutation.md>) | py | Jun 14, 2024 |
@@ -268,6 +269,7 @@ Calculations are based on the code files's byte sizes.
268269
| 1051 | [Height Checker](<https://leetcode.com/problems/height-checker>) | Easy | Daily | [solution](<_1051. Height Checker.md>) | c, py | Jun 09, 2024 |
269270
| 856 | [Score of Parentheses](<https://leetcode.com/problems/score-of-parentheses>) | Medium | | [solution](<_856. Score of Parentheses.md>) | py | Jun 17, 2024 |
270271
| 637 | [Average of Levels in Binary Tree](<https://leetcode.com/problems/average-of-levels-in-binary-tree>) | Easy | | [solution](<_637. Average of Levels in Binary Tree.md>) | py | Jul 03, 2024 |
272+
| 2624 | [Snail Traversal](<https://leetcode.com/problems/snail-traversal>) | Medium | | [solution](<_2624. Snail Traversal.md>) | js | Jul 08, 2024 |
271273
| 2734 | [Lexicographically Smallest String After Substring Operation](<https://leetcode.com/problems/lexicographically-smallest-string-after-substring-operation>) | Medium | | [solution](<_2734. Lexicographically Smallest String After Substring Operation.md>) | py | Jun 29, 2024 |
272274
| 2317 | [Maximum XOR After Operations ](<https://leetcode.com/problems/maximum-xor-after-operations>) | Medium | | [solution](<_2317. Maximum XOR After Operations .md>) | c, cpp, java, py | Jun 24, 2024 |
273275
| 1535 | [Find the Winner of an Array Game](<https://leetcode.com/problems/find-the-winner-of-an-array-game>) | Medium | | [solution](<_1535. Find the Winner of an Array Game.md>) | py | Jun 08, 2024 |
@@ -405,6 +407,7 @@ Calculations are based on the code files's byte sizes.
405407
| 177 | [Nth Highest Salary](<https://leetcode.com/problems/nth-highest-salary>) | Medium | | [solution](<_177. Nth Highest Salary.md>) | sql | May 22, 2024 |
406408
| 2886 | [Change Data Type](<https://leetcode.com/problems/change-data-type>) | Easy | | [solution](<_2886. Change Data Type.md>) | py | May 29, 2024 |
407409
| 2667 | [Create Hello World Function](<https://leetcode.com/problems/create-hello-world-function>) | Easy | | [solution](<_2667. Create Hello World Function.md>) | js | Jul 08, 2024 |
410+
| 2626 | [Array Reduce Transformation](<https://leetcode.com/problems/array-reduce-transformation>) | Easy | | [solution](<_2626. Array Reduce Transformation.md>) | js | Jul 08, 2024 |
408411
| 28 | [Find the Index of the First Occurrence in a String](<https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string>) | Easy | | [solution](<_28. Find the Index of the First Occurrence in a String.md>) | py | May 22, 2024 |
409412
| 69 | [Sqrt(x)](<https://leetcode.com/problems/sqrtx>) | Easy | | [solution](<_69. Sqrt(x).md>) | py | Jun 07, 2024 |
410413
| 176 | [Second Highest Salary](<https://leetcode.com/problems/second-highest-salary>) | Medium | | [solution](<_176. Second Highest Salary.md>) | sql | May 22, 2024 |

markdowns/Questions_By_Recent.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Calculations are based on the date of the first solve.
66

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:---------------------------------------------------------------------------------------------------|:---------------------------------|:----------------|
9+
| 2723 | [Add Two Promises](<https://leetcode.com/problems/add-two-promises>) | Easy | | [solution](<_2723. Add Two Promises.md>) | js | Jul 08, 2024 |
10+
| 2626 | [Array Reduce Transformation](<https://leetcode.com/problems/array-reduce-transformation>) | Easy | | [solution](<_2626. Array Reduce Transformation.md>) | js | Jul 08, 2024 |
11+
| 2624 | [Snail Traversal](<https://leetcode.com/problems/snail-traversal>) | Medium | | [solution](<_2624. Snail Traversal.md>) | js | Jul 08, 2024 |
912
| 2623 | [Memoize](<https://leetcode.com/problems/memoize>) | Medium | | [solution](<_2623. Memoize.md>) | js | Jul 08, 2024 |
1013
| 2621 | [Sleep](<https://leetcode.com/problems/sleep>) | Easy | | [solution](<_2621. Sleep.md>) | js | Jul 08, 2024 |
1114
| 2666 | [Allow One Function Call](<https://leetcode.com/problems/allow-one-function-call>) | Easy | | [solution](<_2666. Allow One Function Call.md>) | js | Jul 08, 2024 |

markdowns/_2624. Snail Traversal.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# 2624. [Snail Traversal](<https://leetcode.com/problems/snail-traversal>)
2+
3+
*All prompts are owned by LeetCode. To view the prompt, click the title link above.*
4+
5+
*[Back to top](<../README.md>)*
6+
7+
------
8+
9+
> *First completed : July 08, 2024*
10+
>
11+
> *Last updated : July 08, 2024*
12+
13+
14+
------
15+
16+
> **Related Topics** : **N/A**
17+
>
18+
> **Acceptance Rate** : **65.577 %**
19+
20+
21+
------
22+
23+
## Solutions
24+
25+
- [m2624.js](<../my-submissions/m2624.js>)
26+
### JavaScript
27+
#### [m2624.js](<../my-submissions/m2624.js>)
28+
```JavaScript
29+
/**
30+
* @param {number} rowsCount
31+
* @param {number} colsCount
32+
* @return {Array<Array<number>>}
33+
*/
34+
Array.prototype.snail = function(rowsCount, colsCount) {
35+
if (this.length !== rowsCount * colsCount) {
36+
return [];
37+
}
38+
39+
const output = [];
40+
for (let r = 0; r < rowsCount; r++) {
41+
output.push([]);
42+
for (let c = 0; c < colsCount; c++) {
43+
if (c % 2 == 0) {
44+
output[output.length - 1].push(this[c * rowsCount + r]);
45+
} else {
46+
output[output.length - 1].push(this[(c + 1) * rowsCount - r - 1]);
47+
}
48+
}
49+
}
50+
return output;
51+
}
52+
53+
/**
54+
* const arr = [1,2,3,4];
55+
* arr.snail(1,4); // [[1,2,3,4]]
56+
*/
57+
```
58+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# 2626. [Array Reduce Transformation](<https://leetcode.com/problems/array-reduce-transformation>)
2+
3+
*All prompts are owned by LeetCode. To view the prompt, click the title link above.*
4+
5+
*[Back to top](<../README.md>)*
6+
7+
------
8+
9+
> *First completed : July 08, 2024*
10+
>
11+
> *Last updated : July 08, 2024*
12+
13+
14+
------
15+
16+
> **Related Topics** : **N/A**
17+
>
18+
> **Acceptance Rate** : **84.48 %**
19+
20+
21+
------
22+
23+
## Solutions
24+
25+
- [e2626.js](<../my-submissions/e2626.js>)
26+
### JavaScript
27+
#### [e2626.js](<../my-submissions/e2626.js>)
28+
```JavaScript
29+
/**
30+
* @param {number[]} nums
31+
* @param {Function} fn
32+
* @param {number} init
33+
* @return {number}
34+
*/
35+
var reduce = function(nums, fn, init) {
36+
nums.forEach(num => init = fn(init, num));
37+
return init;
38+
};
39+
```
40+

0 commit comments

Comments
 (0)