Programowanie konkurencyjneŁatwe

Puzzle zrzucające jajka

Szczegółowy przewodnik i implementacja Python dla problemu „Zagadka upuszczania jaj”.

Oświadczenie o problemie

Łatwe

Napisz funkcję egg_drop(n, k), która zwraca minimalną liczbę prób wymaganych do znalezienia krytycznego piętra w najgorszym przypadku, przy danych n jajach i k piętrach.

Ograniczenia
  • 1 <= n <= 10
  • 1 <= k <= 100

Przykłady

Example 1
Input
egg_drop(2, 10)
Output
4
Explanation

With 2 eggs and 10 floors, we can find the critical floor in at most 4 trials.

Example 2
Input
egg_drop(3, 14)
Output
4
Explanation

With 3 eggs and 14 floors, we can find the critical floor in at most 4 trials.

Need a Hint?
Rozważ użycie struktur danych specyficznych dla programowania dynamicznego, takich jak zestawy lub sterty.
Edge Cases to Watch
  • Puste struktury wejściowe
  • Wejścia jednoelementowe
  • Duże granice liczbowe

Gotowy do rozwiązania?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Otwórz w Edytorze
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Polecane zasoby Pythona

Poszerzaj swoją wiedzę dzięki powiązanym interaktywnym samouczkom, ściągawkom i porównaniom kodów.