[Algorithm][LeetCode 75][Medium] Sort Colors
문제Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.You must solve this problem without using the library's sort function.Example 1Input: nums = [2,0,2,1,1,0]Output: [0,0,1..
[Algorithm][LeetCode 1920] buildArray
배열 인덱스를 활용한 간단한 배열 구성 문제 - buildArrayLeetCode의 배열 문제 중 하나인 “Build Array from Permutation” 문제를 정리해보았습니다.문제 설명0부터 시작하는 순열 배열 nums가 주어졌을 때, ans[i] = nums[nums[i]]가 되도록 배열 ans를 구성하여 반환하는 문제입니다.여기서 0 기반 순열(zero-based permutation)은 0부터 nums.length - 1까지의 정수를 중복 없이 포함한 배열을 의미합니다.예제 1Input: nums = [0,2,1,5,3,4]Output: [0,1,2,4,5,3]설명:ans = [ nums[nums[0]], // nums[0] = 0 → nums[0] = 0 nums[nums[1]], /..