From 63d275cb6babfea82d565ff41cbc7ff35585930b Mon Sep 17 00:00:00 2001 From: SinnoLn Date: Wed, 14 Oct 2026 23:49:21 +0900 Subject: [PATCH] 4065. Rearrange Array by Removing Distinct Values --- ...ge Array by Removing Distinct Values.java" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "leetcode3/\354\235\264\354\247\204\355\235\254/4065. Rearrange Array by Removing Distinct Values.java" diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/4065. Rearrange Array by Removing Distinct Values.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/4065. Rearrange Array by Removing Distinct Values.java" new file mode 100644 index 00000000..b7b59632 --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/4065. Rearrange Array by Removing Distinct Values.java" @@ -0,0 +1,26 @@ +class Solution { + public int[] rearrangeArray(int[] nums) { + // 오름차 순이어야함 + // 연속 같은 수 금지 + + // 숫자 범위 1 ~ 100 + int[] cnt = new int[101]; + int[] ans = new int[nums.length]; + + for(int i=0; i0) { + ans[pos++] = j; + cnt[j]--; + } + if(pos == nums.length) break; + } + } + + return ans; + } +} \ No newline at end of file