solutions to programmers problem sets
- 1. ํด์ (๋์; 4 ๋ฌธ์ )
- 2. ์คํ/ํ (๋ณดํต 6 ๋ฌธ์ )
- 3. ํ (๋ณดํต; 4 ๋ฌธ์ )
- 4. ์ ๋ ฌ (๋์; 3 ๋ฌธ์ )
- 5. ์์ ํ์ (๋์; 4 ๋ฌธ์ )
- 6. ๊ทธ๋ฆฌ๋ (๋ฎ์; 7 ๋ฌธ์ )
- 7. ๋์ ๊ณํ๋ฒ (๋ฎ์; 7 ๋ฌธ์ )
- 8. ๊น์ด/๋๋น ์ฐ์ ํ์ (๋์; 4 ๋ฌธ์ )
- 9. ์ด๋ถํ์ (๋ฎ์; 3๋ฌธ์ )
- 10. ๊ทธ๋ํ (๋ฎ์; 4๋ฌธ์ )
- ์นด์นด์ค ๋ธ๋ผ์ธ๋ ์ฝ๋ฉํ ์คํธ 1์ฐจ 2019
- ์นด์นด์ค ๋ธ๋ผ์ธ๋ ์ฝ๋ฉํ ์คํธ 1์ฐจ 2018
- ์นด์นด์ค ๋ธ๋ผ์ธ๋ ์ฝ๋ฉํ ์คํธ 1์ฐจ 2017
list of useful mechanisms (functions) to remember
- use
unordered_multiset
to insert and erase duplicate keys (1-1. ์์ฃผํ์ง ๋ชปํ ์ ์)- use
iterator
to erase only one and not all duplicate keys - use
unordered_map
instead if need to count number of duplicates: (key, count)- bcuz duplicate keys are iterated separately in multiset
- use
- use
counting principle
to count all the possible combinations (1-3. ์์ฅ ๐)- add
not-chosen-case
to each categories and multiply all categories - if there are certain instances not allowed, simpy calculate number of those and subtract from total counts
- use
backtracking
instead, to actually create all the possible combination representations
- add
- use
sort(v.begin() + i - 1, v.begin() + j)
to sort range (i, j) (4-1. kth number)- make sure to copy array first and then use sort if need to preserve original array