[갓파더 오브 할렘] 에이미 벤더빌트
- 【 사는 이야기 】/시청 미디어
- · 2024. 9. 2.
Hope is the thing with feather
- 【 사는 이야기 】
- · 2024. 9. 2.
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 leng..
Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right. Answermine // originArr의 for문 인덱스는 원래 배열의 값을 순차로 읽어야하기 때문에, 순차적으로 증가하여야만 한다. 그런데 arr에 0을 추가로 삽입하며 사용한 i++에 의하여 순차적으로 읽을 수 없게 되며 실패했다.class Solution { public void duplicateZeros(int[] arr) { // create array int[] originArr = new int[arr.length]; ..
Answersmine : 리스트로 오름차순정렬까진 가능했지만 배열로 리턴하는 부분에서 막혔다. 해결법을 찾는 것보다 솔루션 보고 배우는 게 낫다 싶어서 이동.=> 애초에 바꿔치기 될 대상이니 원래 배열의 값을 유지할 필요가 없다. 배열을 그대로 재활용하는 것이 방법.class Solution { public int[] sortedSquares(int[] nums) { if (nums == null) { throw new IllegalArgumentException(); } List list = new ArrayList(); for (int num : nums) { li..
1295. Find Numbers with Even number of Digitshttps://leetcode.com/problems/find-numbers-with-even-number-of-digits/editorial/Given an array nums of integers, return how many of them contain an even number of digits. Answersmineclass Solution { public int findNumbers(int[] nums) { if (nums == null) { throw new IllegalArgumentException(); } int co..