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
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.
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
https://youtu.be/sjqB70KIfog?si=J8q1xoOABMqMb2u6
Copyright © incolume.com.br since 2010