Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e024617
Create README - LeetHub
xxziiko Apr 7, 2026
e7e7e04
💡 [LTC] Array: 0221-maximal-square
xxziiko Apr 7, 2026
8bd1c52
💡 [LTC] Math: 0009-palindrome-number
xxziiko Apr 7, 2026
b5b69b6
Create README - LeetHub
xxziiko Apr 8, 2026
567dc5c
💡 [LTC] Array: 0064-minimum-path-sum
xxziiko Apr 8, 2026
97f726b
Create README - LeetHub
xxziiko Apr 13, 2026
62dc622
💡 [LTC] Math: 0062-unique-paths
xxziiko Apr 13, 2026
c8c4a64
Create README - LeetHub
xxziiko Apr 15, 2026
af20539
💡 [LTC] Array: 0120-triangle
xxziiko Apr 15, 2026
d63031a
💡 [LTC] Array: 0001-two-sum
xxziiko Apr 23, 2026
9857eed
Create README - LeetHub
xxziiko Apr 27, 2026
00f911e
💡 [LTC] Hash Table: 0383-ransom-note
xxziiko Apr 27, 2026
1fd1ff7
💡 [LTC] Hash Table: 0383-ransom-note
xxziiko Apr 27, 2026
c391ebc
💡 [LTC] Hash Table: 0383-ransom-note
xxziiko Apr 27, 2026
b3b9170
Create README - LeetHub
xxziiko Apr 28, 2026
cf6bf3a
💡 [LTC] Array: 0268-missing-number
xxziiko Apr 28, 2026
31ce972
Create README - LeetHub
xxziiko Jun 10, 2026
b561e20
💡 [LTC] String: 0020-valid-parentheses
xxziiko Jun 10, 2026
79cef02
Create README - LeetHub
xxziiko Jun 11, 2026
5d973d8
💡 [LTC] Two Pointers: 0165-compare-version-numbers
xxziiko Jun 11, 2026
b7bb73c
Create README - LeetHub
xxziiko Jun 11, 2026
9b6f308
💡 [LTC] Math: 0415-add-strings
xxziiko Jun 11, 2026
ea0c8cc
Create README - LeetHub
xxziiko Jun 11, 2026
b1a408e
💡 [LTC] Array: 0049-group-anagrams
xxziiko Jun 11, 2026
0e7af42
Create README - LeetHub
xxziiko Jun 11, 2026
8e2480c
💡 [LTC] Array: 0682-baseball-game
xxziiko Jun 11, 2026
0fee1a9
Create README - LeetHub
xxziiko Jun 11, 2026
4b683ab
💡 [LTC] Array: 0054-spiral-matrix
xxziiko Jun 11, 2026
4ac107a
Create README - LeetHub
xxziiko Jun 11, 2026
8271e1b
💡 [LTC] Array: 0059-spiral-matrix-ii
xxziiko Jun 11, 2026
4674a73
💡 [LTC] Array: 0059-spiral-matrix-ii
xxziiko Jun 11, 2026
69f2074
Create README - LeetHub
xxziiko Jun 12, 2026
cabb0b9
💡 [LTC] Array: 0289-game-of-life
xxziiko Jun 12, 2026
486356d
Create README - LeetHub
xxziiko Jun 12, 2026
0741a79
💡 [LTC] Array: 0498-diagonal-traverse
xxziiko Jun 12, 2026
b59c81d
💡 [LTC] Two Pointers: 0125-valid-palindrome
xxziiko Jun 12, 2026
590d49e
Create README - LeetHub
xxziiko Jun 15, 2026
097af18
💡 [LTC] Array: 0200-number-of-islands
xxziiko Jun 15, 2026
6df45c5
Create README - LeetHub
xxziiko Jun 15, 2026
26871b9
💡 [LTC] Array: 0733-flood-fill
xxziiko Jun 15, 2026
d8f5ead
💡 [LTC] Array: 0682-baseball-game
xxziiko Jun 15, 2026
483ede3
Create README - LeetHub
xxziiko Jun 15, 2026
d9ea960
💡 [LTC] Two Pointers: 0844-backspace-string-compare
xxziiko Jun 15, 2026
8754555
💡 [LTC] Array: 0001-two-sum
xxziiko Jul 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions jiho/0001-two-sum/0001-two-sum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function twoSum(nums: number[], target: number): number[] {
const map = new Map ()

for(const [i, num] of nums.entries()) {
const rest = target - num

if(map.has(rest)) {
return [i, map.get(rest)]
}

map.set(num, i)
}

return []
};
26 changes: 26 additions & 0 deletions jiho/0009-palindrome-number/0009-palindrome-number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function get(x:number) {
let count = 1
while(Math.floor(x / count) >= 10) {
count *=10
}

return count
}

function isPalindrome(x: number): boolean {
if(x < 0) return false

let div= get(x)

while(x > 0) {
let left = Math.floor(x/div)
let right = x % 10

if(left !== right) return false

x = Math.floor((x % div) / 10)
div /= 100
}

return true
};
25 changes: 25 additions & 0 deletions jiho/0020-valid-parentheses/0020-valid-parentheses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function isValid(s: string): boolean {
if(s.length % 2 === 1) return false

const stock = []

for(const char of s) {

if(stock.at(-1) === '(' && char === ')') {
stock.pop()
continue
}
if(stock.at(-1) === '{' && char === '}') {
stock.pop()
continue
}
if(stock.at(-1) === '[' && char === ']') {
stock.pop()
continue
}

stock.push(char)
}

return stock.length === 0
};
58 changes: 58 additions & 0 deletions jiho/0020-valid-parentheses/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<h2><a href="https://leetcode.com/problems/valid-parentheses">20. Valid Parentheses</a></h2><h3>Easy</h3><hr><p>Given a string <code>s</code> containing just the characters <code>&#39;(&#39;</code>, <code>&#39;)&#39;</code>, <code>&#39;{&#39;</code>, <code>&#39;}&#39;</code>, <code>&#39;[&#39;</code> and <code>&#39;]&#39;</code>, determine if the input string is valid.</p>

<p>An input string is valid if:</p>

<ol>
<li>Open brackets must be closed by the same type of brackets.</li>
<li>Open brackets must be closed in the correct order.</li>
<li>Every close bracket has a corresponding open bracket of the same type.</li>
</ol>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;()&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;()[]{}&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

<p><strong class="example">Example 3:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;(]&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">false</span></p>
</div>

<p><strong class="example">Example 4:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;([])&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

<p><strong class="example">Example 5:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;([)]&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">false</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
<li><code>s</code> consists of parentheses only <code>&#39;()[]{}&#39;</code>.</li>
</ul>
18 changes: 18 additions & 0 deletions jiho/0049-group-anagrams/0049-group-anagrams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function groupAnagrams(strs: string[]): string[][] {
// 목표: 애나그램끼리 그룹핑
// 완전탐색 필요. 현재의 요소와 모든 요소를 비교해봐야 한다.

const result = new Map()

for(const str of strs) {
const key = str.split('').sort().join('')

if(!result.has(key)) {
result.set(key, [])
}

result.get(key).push(str)
}

return Array.from(result.values())
};
43 changes: 43 additions & 0 deletions jiho/0049-group-anagrams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<h2><a href="https://leetcode.com/problems/group-anagrams">49. Group Anagrams</a></h2><h3>Medium</h3><hr><p>Given an array of strings <code>strs</code>, group the <span data-keyword="anagram">anagrams</span> together. You can return the answer in <strong>any order</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = [&quot;eat&quot;,&quot;tea&quot;,&quot;tan&quot;,&quot;ate&quot;,&quot;nat&quot;,&quot;bat&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[&quot;bat&quot;],[&quot;nat&quot;,&quot;tan&quot;],[&quot;ate&quot;,&quot;eat&quot;,&quot;tea&quot;]]</span></p>

<p><strong>Explanation:</strong></p>

<ul>
<li>There is no string in strs that can be rearranged to form <code>&quot;bat&quot;</code>.</li>
<li>The strings <code>&quot;nat&quot;</code> and <code>&quot;tan&quot;</code> are anagrams as they can be rearranged to form each other.</li>
<li>The strings <code>&quot;ate&quot;</code>, <code>&quot;eat&quot;</code>, and <code>&quot;tea&quot;</code> are anagrams as they can be rearranged to form each other.</li>
</ul>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = [&quot;&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[&quot;&quot;]]</span></p>
</div>

<p><strong class="example">Example 3:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = [&quot;a&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[&quot;a&quot;]]</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= strs.length &lt;= 10<sup>4</sup></code></li>
<li><code>0 &lt;= strs[i].length &lt;= 100</code></li>
<li><code>strs[i]</code> consists of lowercase English letters.</li>
</ul>
39 changes: 39 additions & 0 deletions jiho/0054-spiral-matrix/0054-spiral-matrix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function spiralOrder(matrix: number[][]): number[] {
// 무엇을 기억해? 숫자 (x) -> 좌표!
// 한번 움직일 때 바뀌는 것 위치
// 언제 종료? 다 돌았을 때
// 예외는? -> 그리드 모서리? 각 경계
const result = []
let top = 0
let right = matrix[0].length -1
let left = 0
let bottom = matrix.length -1

while(top <= bottom && left <= right){
for(let col = left; col <=right; col++ ) {
result.push(matrix[top][col])
}
top+=1

for(let row = top; row <= bottom; row++) {
result.push(matrix[row][right])
}
right--

if(top <= bottom) {
for(let col = right; col >= left; col--) {
result.push(matrix[bottom][col])
}
bottom--
}

if(left <= right) {
for(let row = bottom; row >= top; row--){
result.push(matrix[row][left])
}
left++
}
}

return result
};
26 changes: 26 additions & 0 deletions jiho/0054-spiral-matrix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h2><a href="https://leetcode.com/problems/spiral-matrix">54. Spiral Matrix</a></h2><h3>Medium</h3><hr><p>Given an <code>m x n</code> <code>matrix</code>, return <em>all elements of the</em> <code>matrix</code> <em>in spiral order</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/13/spiral1.jpg" style="width: 242px; height: 242px;" />
<pre>
<strong>Input:</strong> matrix = [[1,2,3],[4,5,6],[7,8,9]]
<strong>Output:</strong> [1,2,3,6,9,8,7,4,5]
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/13/spiral.jpg" style="width: 322px; height: 242px;" />
<pre>
<strong>Input:</strong> matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
<strong>Output:</strong> [1,2,3,4,8,12,11,10,9,5,6,7]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>m == matrix.length</code></li>
<li><code>n == matrix[i].length</code></li>
<li><code>1 &lt;= m, n &lt;= 10</code></li>
<li><code>-100 &lt;= matrix[i][j] &lt;= 100</code></li>
</ul>
41 changes: 41 additions & 0 deletions jiho/0059-spiral-matrix-ii/0059-spiral-matrix-ii.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function generateMatrix(n: number): number[][] {
const matrix = Array.from({ length: n }, (_, i) => Array(n).fill(0));
let num = 0
let top =0
let left = 0
let right = n-1
let bottom = n-1


while(top <= bottom && left <= right) {
//왼 -> 오
for(let col = left; col <= right; col++){
matrix[top][col] = num+=1
}
top++

//위 -> 아래
for(let row = top; row <= bottom; row++) {
matrix[row][right] = num+=1
}
right--

//오 -> 왼
if(left <= right) {
for(let col = right; col >= left; col--) {
matrix[bottom][col] = num+=1
}
}
bottom--

// 아래 -> 위
if(top <= bottom) {
for(let row = bottom; row >= top; row--) {
matrix[row][left] = num+=1
}
}
left++
}

return matrix
};
23 changes: 23 additions & 0 deletions jiho/0059-spiral-matrix-ii/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h2><a href="https://leetcode.com/problems/spiral-matrix-ii">59. Spiral Matrix II</a></h2><h3>Medium</h3><hr><p>Given a positive integer <code>n</code>, generate an <code>n x n</code> <code>matrix</code> filled with elements from <code>1</code> to <code>n<sup>2</sup></code> in spiral order.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/13/spiraln.jpg" style="width: 242px; height: 242px;" />
<pre>
<strong>Input:</strong> n = 3
<strong>Output:</strong> [[1,2,3],[8,9,4],[7,6,5]]
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 1
<strong>Output:</strong> [[1]]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= n &lt;= 20</code></li>
</ul>
20 changes: 20 additions & 0 deletions jiho/0062-unique-paths/0062-unique-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function uniquePaths(m: number, n: number): number {
const dp = Array.from({length: m}, () => Array(n).fill(0))

dp[0][0] = 1
for(let i = 1; i < m; i++){
dp[i][0] = 1
}

for(let j =1; j<n; j ++) {
dp[0][j] = 1
}

for(let i = 1; i < m ; i++) {
for(let j = 1; j <n ; j++) {
dp[i][j] = dp[i-1][j] + dp[i][j-1]
}
}

return dp[m-1][n-1]
};
31 changes: 31 additions & 0 deletions jiho/0062-unique-paths/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h2><a href="https://leetcode.com/problems/unique-paths">62. Unique Paths</a></h2><h3>Medium</h3><hr><p>There is a robot on an <code>m x n</code> grid. The robot is initially located at the <strong>top-left corner</strong> (i.e., <code>grid[0][0]</code>). The robot tries to move to the <strong>bottom-right corner</strong> (i.e., <code>grid[m - 1][n - 1]</code>). The robot can only move either down or right at any point in time.</p>

<p>Given the two integers <code>m</code> and <code>n</code>, return <em>the number of possible unique paths that the robot can take to reach the bottom-right corner</em>.</p>

<p>The test cases are generated so that the answer will be less than or equal to <code>2 * 10<sup>9</sup></code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img src="https://assets.leetcode.com/uploads/2018/10/22/robot_maze.png" style="width: 400px; height: 183px;" />
<pre>
<strong>Input:</strong> m = 3, n = 7
<strong>Output:</strong> 28
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> m = 3, n = 2
<strong>Output:</strong> 3
<strong>Explanation:</strong> From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:
1. Right -&gt; Down -&gt; Down
2. Down -&gt; Down -&gt; Right
3. Down -&gt; Right -&gt; Down
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= m, n &lt;= 100</code></li>
</ul>
Loading