Just binary search eating speed k from 1 to max(piles). Mention edge case to interviewer where if given h < len(piles), then it will be impossible to finish all piles
Leetcode 875. Koko Eating Bananas
Find the minimum integer eating speed k such that the total hours required (sum over piles of ceil(piles[i]/k)) is ≤ h; because the required hours decreases monotonically with k, this is solved by binary searching k between 1 and max(piles).
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Sem observação adicional neste relato público.
They asked Koko eating bananas binary search question but changed the wording to machine learning context. They replaced piles with data sample size and asked for min batch size for which we will satisfy the batch count threshold
Materiais associados
Nenhum anexo público associado a esta pergunta.
Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.
Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.