# Week7 (Apr 29)
## 347. Top K Frequent Elements
### Question
Given an integer array <mark>$nums$</mark> and an integer <mark>$k$</mark>, return the <mark>$k$</mark> most frequent elements. You may return the answer in any order.
**Constraints**:
* $1 <= nums.length <= 105$
* $-104 <= nums[i] <= 104$
* <mark>$k$</mark> is in the range <mark>\[1, the number of unique elements in the array\]</mark>.
* It is **guaranteed** that the answer is unique.
**Follow up**:
Your algorithm's time complexity must be better than $O(n log n)$, where n is the array's size.
### Hand in homework before Saturday.
:::success
[Roger的作業](https://github.com/GametreeRoger/LeetCode/blob/main/LeetCode347.playground/Contents.swift)
[Allen的作業](https://github.com/allen870619/leetcode_practice/blob/main/1-500/347.%20Top%20K%20Frequent%20Elements.playground/Contents.swift)
[woody的作業](https://github.com/woodycatliu/leetcode/tree/main/0347_TopKFrequentElements)
[Wen的作業](https://github.com/Tseng-W/LeetCodePractice/blob/main/LeetCodeStudy.playground/Pages/347.%20Top%20K%20Frequent%20Elements%20.xcplaygroundpage/Contents.swift)
[xander的作業](https://github.com/Takumi47/30Plus/blob/main/30Plus/Problems/347_TopKFrequentElements.swift)
...`Continue filling by yourself`
:::
## 210. Course Schedule II
### Question
There are a total of <mark>numCourses</mark> courses you have to take, labeled from <mark>0</mark> to <mark>numCourses - 1</mark>. You are given an array <mark>prerequisites</mark> where <mark>prerequisites[i] = [$a_i$, $b_i$]</mark> indicates that you must take course <mark>$b_i$</mark> first if you want to take course <mark>$a_i$</mark>.
* For example, the pair <mark>[0, 1]</mark>, indicates that to take course <mark>0</mark> you have to first take course <mark>1</mark>.
Return the ordering of courses you should take to finish all courses. If there are many valid answers, return **any** of them. If it is impossible to finish all courses, return **an empty array**.
### Hand in homework before Saturday.
:::success
[woody的作業](https://github.com/woodycatliu/leetcode/tree/main/0210_CourseSchedule2)
[Roger的作業](https://github.com/GametreeRoger/LeetCode/blob/main/LeetCode210.playground/Contents.swift)
[Allen的作業](https://github.com/allen870619/leetcode_practice/blob/main/1-500/210.%20Course%20Schedule%20II.playground/Contents.swift)
[xander的作業](https://github.com/Takumi47/30Plus/blob/main/30Plus/Problems/210_CourseScheduleII.swift)
...`Continue filling by yourself`
:::