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..b5d5aa0e --- /dev/null +++ "b/leetcode3/\354\240\225\354\247\204\354\230\201/1094. Car Pooling" @@ -0,0 +1,27 @@ +/** + * @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 capacity) { + return false; + } + } + return true; +}; 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; +};