Skip to content

Commit

Permalink
Update 347-Top-K-Frequent-Elements.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad-A0 authored Aug 27, 2022
1 parent a11886a commit 78338ce
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions typescript/347-Top-K-Frequent-Elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ function topKFrequent(nums: number[], k: number): number[] | undefined {
}
}

// The short one solution using map & sorting
function topKFrequent(nums: number[], k: number): number[] {
function topKFrequentNLogN(nums: number[], k: number): number[] {
const map = nums.reduce((acc, num) => {
const currentNumber = acc[String(num)];
acc[num] = currentNumber ? currentNumber + 1 : 1;
Expand Down

0 comments on commit 78338ce

Please sign in to comment.