diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2024-08-15 15:38:11 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2024-08-15 15:38:11 +0900 |
| commit | b6855458c3c74ee93496275ea97bc3ba97a31e07 (patch) | |
| tree | 370bfea2d714c3031c13b8e7398182eceaab7cd1 | |
| parent | 96ca9ae7b33545bb3d7f8797dcd08d043adccc19 (diff) | |
Init
| -rw-r--r-- | 1_array_hashing/top_k_elements.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/1_array_hashing/top_k_elements.py b/1_array_hashing/top_k_elements.py new file mode 100644 index 0000000..e4b0e12 --- /dev/null +++ b/1_array_hashing/top_k_elements.py @@ -0,0 +1,57 @@ +""" +Question + +Top K Elements in List + +Given an integer array nums and an integer k, return the k most frequent elements within the array. + +The test cases are generated such that the answer is always unique. + +You may return the output in any order. + +Example 1: + +Input: nums = [1,2,2,3,3,3], k = 2 + +Output: [2,3] + +Example 2: + +Input: nums = [7,7], k = 1 + +Output: [7] + +Constraints: + + 1 <= nums.length <= 10^4. + -1000 <= nums[i] <= 1000 + 1 <= k <= number of distinct elements in nums. +""" + + +class Solution: + def fn_name(self, parameters) -> return_type: + return return + + + +case1 = case1 +case2 = case2 +case3 = case3 + +solution = Solution() +print(f" fn_name case1: {solution.fn_name(case1args)}") +print(f" fn_name case2: {solution.fn_name(case2args)}") +print(f" fn_name case3: {solution.fn_name(case3args)}") + + +""" +Solution + +url: url +video: video +code: +```fn_name +code +``` +""" |
