- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Discovering Infinite Loops, Handling Custom Iteration, Error handling, Debugging, Testing
Problem
Input: a string containing a sequence of commands separated by semicolons; each command is one of:
"ADD x" (add integer x to a running total),
"MUL x" (multiply running total by x),
"IFZERO goto n" (if running total == 0, jump to the nth command, 1-based),
"PRINT" (append current total to output).
Commands may have extra spaces; ignore blank commands; invalid commands should cause an error with a helpful message.
Output: list of printed integers in order, or an error if a jump targets an invalid line or a command is malformed.
Constraints: input length up to ~10k characters, values fit in 64-bit signed.
Why this tests problem-solving
Requires tokenizing and robust parsing (trimming, splitting, number parsing).
Needs control-flow handling (jumps), loop detection/termination care.
Shows use of Kotlin features: sealed classes, data classes, when, extension functions, exception handling, and idiomatic collection usage.
Видео Discovering Infinite Loops, Handling Custom Iteration, Error handling, Debugging, Testing канала Dr Priyanthi Dassanayake
Input: a string containing a sequence of commands separated by semicolons; each command is one of:
"ADD x" (add integer x to a running total),
"MUL x" (multiply running total by x),
"IFZERO goto n" (if running total == 0, jump to the nth command, 1-based),
"PRINT" (append current total to output).
Commands may have extra spaces; ignore blank commands; invalid commands should cause an error with a helpful message.
Output: list of printed integers in order, or an error if a jump targets an invalid line or a command is malformed.
Constraints: input length up to ~10k characters, values fit in 64-bit signed.
Why this tests problem-solving
Requires tokenizing and robust parsing (trimming, splitting, number parsing).
Needs control-flow handling (jumps), loop detection/termination care.
Shows use of Kotlin features: sealed classes, data classes, when, extension functions, exception handling, and idiomatic collection usage.
Видео Discovering Infinite Loops, Handling Custom Iteration, Error handling, Debugging, Testing канала Dr Priyanthi Dassanayake
Комментарии отсутствуют
Информация о видео
22 мая 2026 г. 21:28:28
00:30:10
Другие видео канала





















