incolume-jedi / coding-dojo

Aqui é mantido um repositório com as soluções que trabalhamos no dojo de codificação da Guilda JEDI (Junta Especializada de Desenvolvimento e Inovação) em https://discord.gg/eBNamXVtBW
https://incolume-jedi.github.io/coding-dojo/
The Unlicense
2 stars 4 forks source link

[new-dojo] Top K Frequent Elements #274

Open britodfbr opened 2 weeks ago

britodfbr commented 2 weeks ago

Coding Dojo

Guilda JEDI Incolume - Grupo Python Incolume


Problema

Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

Exemplos

Example 1:

Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2]

Example 2:

Input: nums = [1], k = 1 Output: [1]

Follow up: Your algorithm's time complexity must be better than O(n log n), where n is the array's size.

Spoiler? Considerar em caso de fatoração: > modo pythônico > sem condicionais > estruturas performáticas > redução de complexidade ciclomática > análise assintótica de algoritmos (big O)

N/A - Exemplos de solução e resposta do problema. Geralmente utilizado para validar os testes do TDD.

Constraints:

1 <= nums.length <= 105 -104 <= nums[i] <= 104 k is in the range [1, the number of unique elements in the array]. It is guaranteed that the answer is unique.

Artefatos

Referências

Copyright © incolume.com.br since 2010