[Algorithm][LeetCode 2929][Medium] Distribute Candies Among Children II
문제두 양의 정수 n과 limit이 주어졌을 때,세 명의 아이에게 사탕을 나누어 주는 방법의 총 수를 반환하시오. 단, 어떤 아이도 limit개를 초과해서 받을 수 없다.예시 1:Input: n = 5, limit = 2Output: 3설명: (1, 2, 2), (2, 1, 2), (2, 2, 1) 의 3가지 방법 존재예시 2:Input: n = 3, limit = 3Output: 10설명: (0,0,3), (0,1,2), (0,2,1), (0,3,0), (1,0,2), (1,1,1), (1,2,0), (2,0,1), (2,1,0), (3,0,0)제약 사항1 ≤ n ≤ 1061 ≤ limit ≤ 106풀이1. 브루트포스 접근법a, b의 값을 고정하면 c는 n - a - b로 자동 결정됩니다.하지만 lim..
[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..