From e2fd6042207d8ea70812e2e3e981ae925bfd7dd1 Mon Sep 17 00:00:00 2001 From: Jinyoung Jeong <80400463+jyoung2419@users.noreply.github.com> Date: Tue, 13 Oct 2026 22:19:25 +0900 Subject: [PATCH 1/3] Implement minQueenMoves function for queen moves --- ...4061. Minimum Queen Moves to Reach Target" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "leetcode3/\354\240\225\354\247\204\354\230\201/4061. Minimum Queen Moves to Reach Target" diff --git "a/leetcode3/\354\240\225\354\247\204\354\230\201/4061. Minimum Queen Moves to Reach Target" "b/leetcode3/\354\240\225\354\247\204\354\230\201/4061. Minimum Queen Moves to Reach Target" new file mode 100644 index 00000000..ca65831b --- /dev/null +++ "b/leetcode3/\354\240\225\354\247\204\354\230\201/4061. Minimum Queen Moves to Reach Target" @@ -0,0 +1,19 @@ +/** + * @param {number[]} source + * @param {number[]} target + * @return {number} + */ +var minQueenMoves = function(source, target) { + // 8x8 + // 같은 좌표: 0 + // 대각선 라인, 같은 행, 열: 1 + // else: 2 + if (source[0] == target[0] && source[1] == target[1]) { + return 0; + } if ( + (Math.abs(source[0] - target[0]) == Math.abs(source[1] - target[1])) || (source[0] == target[0] && source[1] !== target[1]) || + (source[0] !== target[0] && source[1] == target[1]) + ) return 1; + + return 2; +}; From 6cde5e41737cd438bf0c060f2e8b89826676ec6d Mon Sep 17 00:00:00 2001 From: Jinyoung Jeong <80400463+jyoung2419@users.noreply.github.com> Date: Tue, 13 Oct 2026 22:41:33 +0900 Subject: [PATCH 2/3] Add carPooling function for trip capacity validation Implement carPooling function to check capacity. --- .../1094. Car Pooling" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" diff --git "a/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" "b/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" new file mode 100644 index 00000000..20ce939f --- /dev/null +++ "b/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" @@ -0,0 +1,20 @@ +/** + * @param {number[][]} trips + * @param {number} capacity + * @return {boolean} + */ +var carPooling = function(trips, capacity) { + // trips[i] = [numPassengers, from, to] + // nP 승객이 from에서 타서 to에서 내림 + let arr = new Array(1000).fill(0); + for (let i = 0; i Date: Tue, 13 Oct 2026 22:49:10 +0900 Subject: [PATCH 3/3] Update 1094. Car Pooling --- .../1094. Car Pooling" | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git "a/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" "b/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" index 20ce939f..b5d5aa0e 100644 --- "a/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" +++ "b/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" @@ -12,9 +12,16 @@ var carPooling = function(trips, capacity) { let from = trips[i][1]; let to = trips[i][2]; - arr[from] += np; - arr[to] -= np; + arr[from] += nP; + arr[to] -= nP; } - if (capacity) + let count = 0; + for (let j = 0; j < arr.length; j++){ + count += arr[j]; + if (count > capacity) { + return false; + } + } + return true; };