All Posts

Leetcode 347: Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements from the array. The answer may be returned in any order.

Leetcode 451: Sort Characters By Frequency

Given a string, sort its characters based on their frequency of occurrence in descending order. If multiple solutions are possible, any valid answer is acceptable. The frequency of each character refers to how many times it appears in the string.

Leetcode 692: Top K Frequent Words

Given a list of words and an integer k, return the k most frequent words in the list. The words should be sorted by their frequency in descending order. If two words have the same frequency, they should be sorted lexicographically.