-
283. Move Zeroes javaLeetCode_Study_Plan/Programming Skills 2022. 9. 20. 23:52
https://leetcode.com/problems/move-zeroes/?envType=study-plan&id=programming-skills-i
class Solution { public void moveZeroes(int[] nums) { int from = -1, to = -1; for(int i = 0 ; i < nums.length; i++){ if (nums[i] == 0){ from = i; } for (int j = i ; j < nums.length; j++){ if (nums[j] != 0 && from > -1){ to = j; nums[from] = nums[to]; nums[to] = 0; from = -1; to = -1; break; } } // System.out.println(Arrays.toString(nums)); } } }
'LeetCode_Study_Plan > Programming Skills' 카테고리의 다른 글
1572. Matrix Diagonal Sum java (0) 2022.09.21 1672. Richest Customer Wealth java (0) 2022.09.21 1588. Sum of All Odd Length Subarrays java (1) 2022.09.20 1232. Check If It Is a Straight Line java (1) 2022.09.20 496. Next Greater Element I java (0) 2022.09.20