Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5695d13
217 / Contains Duplicate / Easy / 12m
oh-chaeyeon Sep 24, 2024
9b2a2df
268 / Missing number / Easy / 10m
oh-chaeyeon Sep 24, 2024
a20252e
121 / Best Time to buy and sell stock / Easy / 32m
oh-chaeyeon Sep 24, 2024
8f136a5
253 / Meeting Rooms / Easy / 20m
oh-chaeyeon Sep 24, 2024
3024e53
15 / 3Sum / Medium / 22m
oh-chaeyeon Sep 24, 2024
ed4b872
252 / Meeting Rooms / Easy / 20m (๋ฌธ์ œ๋ฒˆํ˜ธ ์ˆ˜์ •)
oh-chaeyeon Sep 24, 2024
53a320d
242 / Valid Anagram / Easy / 11m
oh-chaeyeon Oct 1, 2024
c4a58be
238 / Product of Arrays Except Self / Medium / 14m
oh-chaeyeon Oct 1, 2024
fd63ce5
191 / Number of 1 Bits / Easy / 14m
oh-chaeyeon Oct 1, 2024
fea7405
100 / Same Tree / Easy / 12m
oh-chaeyeon Oct 1, 2024
ff58ada
746 / Min Cost Climbing Stairs / Easy / 50m
oh-chaeyeon Oct 1, 2024
49da333
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Oct 1, 2024
d800224
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Oct 8, 2024
7735104
49 / Group Anagrams / Medium / 43m
oh-chaeyeon Oct 8, 2024
84ca093
190 / Reverse Bits / Easy / 33m
oh-chaeyeon Oct 8, 2024
2acdf2c
125 / Valid Palindrome / Easy / 28m
oh-chaeyeon Oct 8, 2024
4937727
322 / Coin Change / Medium / 1h 18m
oh-chaeyeon Oct 8, 2024
2daaa4c
206 / Reverse Linked list / Easy / 27m
oh-chaeyeon Oct 8, 2024
8141ed1
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Oct 15, 2024
64fd3b5
1 / Two Sum / Easy / 15m 55s
oh-chaeyeon Oct 15, 2024
86623d5
104 / Maximum Depth of Binary Tree / Easy / 11m 46s
oh-chaeyeon Oct 15, 2024
2831c87
141 / Linked List Cycle / Easy / 37m 26s
oh-chaeyeon Oct 15, 2024
f86608e
202 /Happy Number / Easy / 20m 6s
oh-chaeyeon Oct 15, 2024
e0fccd7
20 / Valid Parentheses / Easy / 18m 24s
oh-chaeyeon Oct 15, 2024
d8fa1de
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Oct 22, 2024
61753aa
338 / Counting Bits / Easy / 16m
oh-chaeyeon Oct 22, 2024
47ea9b0
70 / Climbing Stairs / Easy / 16m 30s
oh-chaeyeon Oct 22, 2024
f72bab8
21 / Merge two Sorted Lists / Easy / 40m 32s
oh-chaeyeon Oct 22, 2024
d3637a1
48 / Rotate Image / Medium / 36m 15s
oh-chaeyeon Oct 22, 2024
91dc0f0
1046 / Last Stone Weight / Easy / 7m 51s
oh-chaeyeon Oct 22, 2024
1f60059
271 / Encode and Decode Strings / Medium / 14m
oh-chaeyeon Oct 29, 2024
9de1b77
198 / House Robber / Medium / 26m 36s
oh-chaeyeon Oct 29, 2024
f031a31
66 / Plus One / Easy / 9m 28s
oh-chaeyeon Oct 29, 2024
38a2fe1
703 / Kth Largest Element in a Stream / Easy / 40m 51s
oh-chaeyeon Oct 29, 2024
5210093
704 / Binary Search / Easy / 9m 26s
oh-chaeyeon Oct 29, 2024
6cc0a28
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Oct 29, 2024
bac9df5
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Nov 5, 2024
59e79d8
136 / Single Number / Easy / 4m 52s
oh-chaeyeon Nov 5, 2024
df48108
110 / Balanced Binary Tree / Easy / 16m 44s
oh-chaeyeon Nov 5, 2024
bf2bb0e
54 / Spiral Matrix / Medium / 53m 19s
oh-chaeyeon Nov 5, 2024
d75f703
973 / K Closest points to Origin / Medium / 12m 42s
oh-chaeyeon Nov 5, 2024
eae2d4c
155 / Min Stack / Medium / 1h 2m 56s
oh-chaeyeon Nov 5, 2024
6894655
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Nov 12, 2024
d1ae919
128 / Longest consecutive sequence / Medium / 31m 17s
oh-chaeyeon Nov 12, 2024
db6e784
371 / Sum of two Integers / Medium / 15m 48s
oh-chaeyeon Nov 12, 2024
efe5ca2
208 / Implement Trie Prefix Tree / Medium / 57m 29s
oh-chaeyeon Nov 12, 2024
cd94c02
226 / Invert Binary Tree / Easy / 30m 34s
oh-chaeyeon Nov 12, 2024
bff8310
543 / Diameter of Binary Tree / Easy / 31m 55s
oh-chaeyeon Nov 12, 2024
ff6760b
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Nov 19, 2024
5f23ce0
201 / Binary Tree Level Order Traversal / Medium / 21m 49s
oh-chaeyeon Nov 19, 2024
91c0914
572 / Subtree Of Another Tree / Easy / 25m 09s
oh-chaeyeon Nov 19, 2024
a5d9426
213 / House Robber II / Medium / 20m 31s
oh-chaeyeon Nov 19, 2024
89099b6
207 / Course Schedule / Medium / 21m 49s
oh-chaeyeon Nov 19, 2024
fccee21
150 / Evaluate Reverse Polish Notation / Medium / 14m 58s
oh-chaeyeon Nov 19, 2024
2720f06
56 / Merge Intervals / Medium / 23m 25s
oh-chaeyeon Nov 26, 2024
13fc2c3
1584 / Min Cost to Connect all points / Medium / 1h+
oh-chaeyeon Nov 26, 2024
78f1f2c
235 / Lowest Common ancestor of a Binary Search Tree / Medium / 9m 37s
oh-chaeyeon Nov 26, 2024
812d16f
139 / Word Break / Medium / 12m 49s
oh-chaeyeon Nov 26, 2024
622454d
215 / Kth largest element in an Array / Medium / 30m+
oh-chaeyeon Nov 26, 2024
e96ead6
Merge branch 'master' into oh-chaeyeon
oh-chaeyeon Nov 26, 2024
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
30 changes: 30 additions & 0 deletions oh-chaeyeon/139_Word_Break.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @param {string} s
* @param {string[]} wordDict
* @return {boolean}
*/
var wordBreak = function (s, wordDict) {
const wordSet = new Set(wordDict);
const dp = new Array(s.length + 1).fill(false);
dp[0] = true;

for (let i = 1; i <= s.length; i++) {
for (const word of wordSet) {
const wordLength = word.length;
if (
i >= wordLength &&
dp[i - wordLength] &&
s.substring(i - wordLength, i) === word
) {
dp[i] = true;
break;
}
}
}

return dp[s.length];
};

// Time taken : 12m 49s
// Runtime : 3ms
// Memory : 51.24MB
41 changes: 41 additions & 0 deletions oh-chaeyeon/1584_Min_Cost_to_Connect_all_points.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @param {number[][]} points
* @return {number}
*/
var minCostConnectPoints = function (points) {
const n = points.length;
const dist = new Array(n).fill(Infinity);
const visited = new Array(n).fill(false);
dist[0] = 0;
let cost = 0;

for (let i = 0; i < n; i++) {
let minCost = Infinity;
let currentNode = -1;

for (let j = 0; j < n; j++) {
if (!visited[j] && dist[j] < minCost) {
minCost = dist[j];
currentNode = j;
}
}

visited[currentNode] = true;
cost += minCost;

for (let nextNode = 0; nextNode < n; nextNode++) {
if (!visited[nextNode]) {
const manhattanDistance =
Math.abs(points[currentNode][0] - points[nextNode][0]) +
Math.abs(points[currentNode][1] - points[nextNode][1]);
dist[nextNode] = Math.min(dist[nextNode], manhattanDistance);
}
}
}

return cost;
};

// Time taken : 1h+
// Runtime : 33ms
// Memory : 52.37MB
46 changes: 46 additions & 0 deletions oh-chaeyeon/215_Kth largest_element_in_an_Array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @param {number[]} nums
* @param {number} k
* @return {number}
*/
var findKthLargest = function (nums, k) {
const maxHeap = new MaxPriorityQueue();

for (const num of nums) {
maxHeap.enqueue(num);
}

for (let i = 0; i < k - 1; i++) {
maxHeap.dequeue();
}
return maxHeap.front().element;
};

// Time taken : 16m 50s
// Runtime : 148ms
// Memory : 77.60MB

//----------------------------------------------------

/**
* @param {number[]} nums
* @param {number} k
* @return {number}
*/
var findKthLargest = function (nums, k) {
const offset = 10000;
const count = new Array(20001).fill(0);

for (let num of nums) {
count[num + offset]++;
}

let total = 0;
for (let i = count.length - 1; i >= 0; i--) {
total += count[i];
if (total >= k) return i - offset;
}
};

// Runtime : 5ms
// Memory : 58.40MB
30 changes: 30 additions & 0 deletions oh-chaeyeon/235_Lowest_Common_ancestor_of_a_Binary_Search_Tree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/

/**
* @param {TreeNode} root
* @param {TreeNode} p
* @param {TreeNode} q
* @return {TreeNode}
*/
var lowestCommonAncestor = function (root, p, q) {
while (root) {
if (p.val < root.val && q.val < root.val) {
root = root.left;
} else if (p.val > root.val && q.val > root.val) {
root = root.right;
} else {
return root;
}
}
return null;
};

// Time taken : 9m 37s
// Runtime : 56ms
// Memory : 58.70MB
29 changes: 29 additions & 0 deletions oh-chaeyeon/56_Merge_Intervals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @param {number[][]} intervals
* @return {number[][]}
*/
var merge = function (intervals) {
if (intervals.length === 0) return [];
intervals.sort((a, b) => a[0] - b[0]);

const merged = [intervals[0]];

for (let i = 1; i < intervals.length; i++) {
const current = intervals[i];

if (current[0] <= merged[merged.length - 1][1]) {
merged[merged.length - 1][1] = Math.max(
merged[merged.length - 1][1],
current[1]
);
} else {
merged.push(current);
}
}

return merged;
};

// Time taken : 23m 25s
// Runtime : 7ms
// Memory : 59.04MB
Loading