본문 바로가기

코딩테스트20

[백준 14503] 백준 로봇청소기 Javascript 문제 이름 백준 14503 로봇청소기 문제 풀기 전 생각 눈물나게 어려웠다 ... 이것이 ... 골드 5 ?????? 다들 이런걸 푼단 말이야 ...? 난이도는 골드 5다. 새롭게 알게 된 것 , 기억할 것 1. 방향에 따른 이동이 있는 문제라면 dx = [0,0,-1,1] dy=[-1,1,0,0] 이동에 따른 좌표를 만들어서 let nx = x + dx[0]; let ny = y + dy[0] 이렇게 왔다갔다 해주는게 좋다 알기 전엔 case 문으로 이동시켰는데 머리 깨질뻔 .... 2. 후진하는 경우 정답이 안나와서 뭐가문제지 .. 하고 보고있는데 후진하는 경우 좌표를 잘못 설정 해줬다. 나는 삼항 연산자를 써서 let bd = nd >= 2 ? nd - 2 : nd + 2; 이렇게 .. 써줬는데 다.. 2023. 10. 18.
[Leetcode/JS] 350. Intersection of Two Arrays II 문제링크 350. Intersection of Two Arrays II https://leetcode.com/problems/intersection-of-two-arrays-ii/description/ Intersection of Two Arrays II - LeetCode Can you solve this real interview question? Intersection of Two Arrays II - Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you.. 2023. 7. 18.
[Leetcode/JS] 226. Invert Binary Tree 문제링크 226. Invert Binary Tree https://leetcode.com/problems/invert-binary-tree/description/ Invert Binary Tree - LeetCode Can you solve this real interview question? Invert Binary Tree - Given the root of a binary tree, invert the tree, and return its root. Example 1: [https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg] Input: root = [4,2,7,1,3,6,9] Output: [4 leetcode.com 문제 설명 Give.. 2023. 7. 18.
[Leetcode/JS] 257. Binary Tree Paths 문제링크 https://leetcode.com/problems/binary-tree-paths/ Binary Tree Paths - LeetCode Can you solve this real interview question? Binary Tree Paths - Given the root of a binary tree, return all root-to-leaf paths in any order. A leaf is a node with no children. Example 1: [https://assets.leetcode.com/uploads/2021/03/12/paths-tree.jpg] In leetcode.com 기억하면 좋을 것 JavaScript에서 배열을 새로운 변수에 할당하는 경우 새로운 배.. 2023. 7. 17.