목록LeetCode (13)
개발자도전

[문제] Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k element..

[문제] Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k ele..

[문제] You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a ..

[문제] Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not written. Do the above modifications to the input array in place and do not return anything. 고정 길이 정수 배열 배열이 주어졌을 때, 나머지 요소들을 오른쪽으로 이동시키면서 0의 각 발생을 반복한다. 원래 배열의 길이를 초과하는 요소는 기록되지 않습니다. 위의 수정 작업을 제자리에 있는 입력 ..

[문제] Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. 감소하지 않는 순서로 정렬된 정수 배열을 정렬시켜 각 값의 제곱을 반환시키기. 예 1. Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100] 예 2. Input: nums = [-7,-3,2,3,11] Output: [4,9,9,49,121] [답] for문으로 값을 빼준 후 i번째에 있는 값을 곱해서 다시 대입해주었다. 후 for문 밖에서 Arrays.sort함수를 사용해 nums 배열을 다시 정렬시켜주고 ret..

[문제] Given an array nums of integers, return how many of them contain an even number of digits. 자리 수가 짝수인 개수 반환하기. 예 1. Input: nums = [12,345,2,6,7896] Output: 2 - 12와 7896만 2자리, 4자리 수로 짝수라서 2가 반환 됨. 예 2. Input: nums = [555,901,482,1771] Output: 1 - 1771만 4자리수로 짝수라 1이 반환됨. [답] nums에 있는 수들을 for문으로 빼서 숫자를 문자열로 바꿔주었다. 바꾼 문자열의 길이를 2로 나눴을 경우 나머지가 0이면 짝수라는 뜻이니까 이 때 count를 1 더해주도록 해주었다. 그리고 그 count값을 r..