본문 바로가기

👨‍💻 Two pointers5

[leetcode/JS] 283_Move Zeroes 풀이 🎲 문제 Move Zeroes - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 283. Move Zeroes Easy 정수 배열 nums가 주어지면 0이 아닌 요소의 상대적인 순서를 유지하면서 모든 0을 끝으로 이동합니다. 배열의 복사본을 만들지 않고 이 작업을 제자리에서 수행해야 합니다. 더보기 Given an integer array nums, move all 0's to the end of it while maintaining the relative or.. 2022. 11. 20.
[leetcode/JS] 27_Remove Element 풀이 🎲 문제 Remove Element - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 27. Remove Element Easy 정수 배열 "nums"와 정수 "val"이 주어지면 "nums"에서 발생하는 모든 "val"을 제거합니다. 요소의 상대적 순서는 변경될 수 있습니다. 일부 언어에서는 배열의 길이를 변경할 수 없으므로, 대신 배열의 첫 번째 부분인 "nums"에 결과를 배치해야 합니다. 더 형식적으로, 중복을 제거한 후에 "k" 요소가 있다면, "num.. 2022. 11. 13.
[leetcode/JS] 202_Happy Number 풀이 🎲 문제 Happy Number - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 202. Happy Number Easy 숫자 n이 happy한지 확인하는 알고리즘을 작성하세요. happy number 는 다음 프로세스에 의해 정의된 숫자 입니다. 임의의 양의 정수로 시작하여, 숫자를 해당 자릿수 제곱의 합으로 바꿉니다. 숫자가 1이 될 때까지 프로세스를 반복하거나(그 값이 머무를 위치) 1을 포함하지 않는 주기에서 끝없이 반복합니다. 이 프로세스가 1로 끝나.. 2022. 11. 13.
[leetcode/JS] 75_Sorted Colors 풀이 🎲 문제 Sort Colors - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 75. Sort Colors Medium 빨간색, 흰색 또는 파란색으로 채색된 n 개의 객체가 있는 배열 nums 가 주어지면 동일한 색상의 객체가 in-place 하도록 해당 위치에서 정렬하고 색상은 빨간색, 흰색, 파란색으로 지정합니다. 정수 0, 1, 2는 하여 빨강, 흰색, 파랑을 각각 나타냅니다. 라이브러리의 sort 함수를 사용하지 않고 이 문제를 해결해야 합니다. Exa.. 2022. 11. 13.
[leetcode/JS] 724_Find Pivot Index 풀이 🎲 문제 Find Pivot Index - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 724. Find Pivot Index Easy 정수 배열 nums가 주어지면, 이 배열의 pivot index 계산합니다. pivot index 는 피벗 인덱스는 인덱스 왼쪽에 있는 모든 숫자의 합이 인덱스 오른쪽에 있는 모든 숫자의 합과 같은 인덱스입니다. 인덱스가 배열의 왼쪽 가장자리에 있으면 왼쪽에 요소가 없기 때문에 왼쪽 합계는 0 입니다. 이는 어레이의 오른쪽 가.. 2022. 11. 12.