From e23d90cb8244fc2351733effb9d8badb28aed333 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Wed, 19 Aug 2026 13:05:47 -0400 Subject: [PATCH] docs(docs): add study decks, new reference pages, and fix header image path --- README.md | 2 +- docs/02-concepts/01-arrays-and-strings.mdx | 6 +++ docs/02-concepts/02-hashing.mdx | 6 +++ docs/02-concepts/03-binary-search.mdx | 6 +++ docs/03-guides/02-two-pointers.mdx | 6 +++ docs/03-guides/03-prefix-sum.mdx | 6 +++ docs/03-guides/04-sliding-window.mdx | 6 +++ docs/reference/01-reverse-string.mdx | 45 ++++++++++++++++ .../02-squares-of-a-sorted-array.mdx | 54 +++++++++++++++++++ .../(two-pointers)/01-reverse-string.mdx | 10 ---- .../02-squares-of-a-sorted-array.mdx | 5 -- 11 files changed, 136 insertions(+), 16 deletions(-) create mode 100644 docs/reference/01-reverse-string.mdx create mode 100644 docs/reference/02-squares-of-a-sorted-array.mdx delete mode 100644 docs/solutions/(two-pointers)/01-reverse-string.mdx delete mode 100644 docs/solutions/(two-pointers)/02-squares-of-a-sorted-array.mdx diff --git a/README.md b/README.md index 1474203..006ac3a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- header + header

diff --git a/docs/02-concepts/01-arrays-and-strings.mdx b/docs/02-concepts/01-arrays-and-strings.mdx index 99c7e30..32c14ff 100644 --- a/docs/02-concepts/01-arrays-and-strings.mdx +++ b/docs/02-concepts/01-arrays-and-strings.mdx @@ -63,3 +63,9 @@ Random access in this context means that you can access an element at any index + +## Study deck + +Drill the essentials — click the deck, then use the arrow keys. + + diff --git a/docs/02-concepts/02-hashing.mdx b/docs/02-concepts/02-hashing.mdx index 45716b1..0675002 100644 --- a/docs/02-concepts/02-hashing.mdx +++ b/docs/02-concepts/02-hashing.mdx @@ -28,3 +28,9 @@ Appending to the end of a list is amortized O(1) time complexity. This means tha Random access in this context means that you can access an element at any index in constant time. ::: + +## Study deck + +Drill the essentials — click the deck, then use the arrow keys. + + diff --git a/docs/02-concepts/03-binary-search.mdx b/docs/02-concepts/03-binary-search.mdx index 7e00cfd..903714a 100644 --- a/docs/02-concepts/03-binary-search.mdx +++ b/docs/02-concepts/03-binary-search.mdx @@ -28,3 +28,9 @@ Appending to the end of a list is amortized O(1) time complexity. This means tha Random access in this context means that you can access an element at any index in constant time. ::: + +## Study deck + +Drill the essentials — click the deck, then use the arrow keys. + + diff --git a/docs/03-guides/02-two-pointers.mdx b/docs/03-guides/02-two-pointers.mdx index 5518bcb..8f116fe 100644 --- a/docs/03-guides/02-two-pointers.mdx +++ b/docs/03-guides/02-two-pointers.mdx @@ -12,3 +12,9 @@ This page is a scaffold. Notes, canonical problems, and template code are not wr + +## Study deck + +Drill the essentials — click the deck, then use the arrow keys. + + diff --git a/docs/03-guides/03-prefix-sum.mdx b/docs/03-guides/03-prefix-sum.mdx index 1bb054f..6083051 100644 --- a/docs/03-guides/03-prefix-sum.mdx +++ b/docs/03-guides/03-prefix-sum.mdx @@ -6,3 +6,9 @@ description: 'Precomputed cumulative state for O(1) range queries.' :::warning[Under construction] This page is a scaffold. Notes, canonical problems, and template code are not written yet. ::: + +## Study deck + +Drill the essentials — click the deck, then use the arrow keys. + + diff --git a/docs/03-guides/04-sliding-window.mdx b/docs/03-guides/04-sliding-window.mdx index 0a9d65c..298759c 100644 --- a/docs/03-guides/04-sliding-window.mdx +++ b/docs/03-guides/04-sliding-window.mdx @@ -6,3 +6,9 @@ description: 'Two pointers plus incremental state between them.' :::warning[Under construction] This page is a scaffold. Notes, canonical problems, and template code are not written yet. ::: + +## Study deck + +Drill the essentials — click the deck, then use the arrow keys. + + diff --git a/docs/reference/01-reverse-string.mdx b/docs/reference/01-reverse-string.mdx new file mode 100644 index 0000000..fe6b466 --- /dev/null +++ b/docs/reference/01-reverse-string.mdx @@ -0,0 +1,45 @@ +--- +title: '344. Reverse String' +description: Write a function that reverses a string. The input string is given as an array of characters s +sidebar: + badge: 'Easy' +--- + +Two Pointers + +:::warning +You must do this by modifying the input array in-place with O(1) extra memory. +::: + +### Example 1: +- Input: `s = ["h","e","l","l","o"]` +- Output: `["o","l","l","e","h"]` + +### Example 2: +- Input: `s = ["H","a","n","n","a","h"]` +- Output: `["h","a","n","n","a","H"]` + +### Constraints: + +- `1 <= s.length <= 10^5` +- `s[i]` is a printable ascii character. + +## Solution + +```js +/** + * @param {character[]} s + * @return {void} Do not return anything, modify s in-place instead. + */ + +var reverseString = function(s) { + let i = 0; + let j = s.length - 1; + + while (i < j) { + [s[i], s[j]] = [s[j], s[i]]; + j--; + i++; + } +}; +``` diff --git a/docs/reference/02-squares-of-a-sorted-array.mdx b/docs/reference/02-squares-of-a-sorted-array.mdx new file mode 100644 index 0000000..b8a7dc1 --- /dev/null +++ b/docs/reference/02-squares-of-a-sorted-array.mdx @@ -0,0 +1,54 @@ +--- +title: '977. Squares of a Sorted Array' +description: Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order +sidebar: + badge: 'Easy' +--- + +Two Pointers + +::::warning +Squaring each element and sorting the new array is very trivial, could you find an O(n) solution using a different approach? +:::: + +### Example 1: +- Input: `nums = [-4,-1,0,3,10]` +- Output: `[0,1,9,16,100]` +- Explanation: After squaring, the array becomes `[16,1,0,9,100]`. After sorting, it becomes `[0,1,9,16,100]`. + +### Example 2: +- Input: `nums = [-7,-3,2,3,11]` +- Output: `[4,9,9,49,121]` + +### Constraints: + +- `1 <= nums.length <= 10^4` +- `-10^4 <= nums[i] <= 10^4` +- `nums` is sorted in non-decreasing order. + +## Solution + +```js +/** + * @param {number[]} nums + * @return {number[]} + */ +var sortedSquares = function(nums) { + let n = nums.length; + let ans = new Array(nums.length); + let left = 0, right = nums.length - 1; + + for (let i = n -1; i >= 0; i--){ + let square; + if(Math.abs(nums[left]) < Math.abs(nums[right])){ + square = nums[right]; + right--; + }else{ + square = nums[left]; + left++; + } + ans[i] = square*square; + } + return ans; +}; +``` diff --git a/docs/solutions/(two-pointers)/01-reverse-string.mdx b/docs/solutions/(two-pointers)/01-reverse-string.mdx deleted file mode 100644 index f49c32a..0000000 --- a/docs/solutions/(two-pointers)/01-reverse-string.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: '344. Reverse String' -sidebar: - badge: 'Easy' ---- - -Two Pointers -[Source](https://leetcode.com/problems/reverse-string/) - -## Description diff --git a/docs/solutions/(two-pointers)/02-squares-of-a-sorted-array.mdx b/docs/solutions/(two-pointers)/02-squares-of-a-sorted-array.mdx deleted file mode 100644 index f893cee..0000000 --- a/docs/solutions/(two-pointers)/02-squares-of-a-sorted-array.mdx +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar: - icon: code - badge: '977' ----