Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Largest Even Integer | Leetcode | Java solution (3798)

Автор: HeapStacked

Загружено: 2026-01-05

Просмотров: 39

Описание:

Today I solve the Largest Even String problem by iterating backwards through the string to find the last occurrence of the character '2'. Since the largest possible even number must end in an even digit (and retain the most significant digits), I return the substring up to that index, effectively removing only the trailing odd numbers.



3798. Largest Even Number

You are given a string s consisting only of the characters '1' and '2'.

You may delete any number of characters from s without changing the order of the remaining characters.

Return the largest possible resultant string that represents an even integer. If there is no such string, return the empty string "".



Example 1:

Input: s = "1112"

Output: "1112"

Explanation:

The string already represents the largest possible even number, so no deletions are needed.

Example 2:

Input: s = "221"

Output: "22"

Explanation:

Deleting '1' results in the largest possible even number which is equal to 22.

Example 3:

Input: s = "1"

Output: ""

Explanation:

There is no way to get an even number.



Constraints:

1 = s.length = 100
s consists only of the characters '1' and '2'.

Largest Even Integer | Leetcode | Java solution (3798)

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Mirror Distance of an Integer Leetcode | Java solution (3783)

Mirror Distance of an Integer Leetcode | Java solution (3783)

Алгоритмическое mock-собеседование | Ex-Team Lead Яндекс

Алгоритмическое mock-собеседование | Ex-Team Lead Яндекс

What is Armstrong Number? | Python Program Explained Step by Step| Skilluron

What is Armstrong Number? | Python Program Explained Step by Step| Skilluron

The Windows 11 Disaster That's Killing Microsoft

The Windows 11 Disaster That's Killing Microsoft

Путин перестал говорить о войне | Что случилось (English subtitles)

Путин перестал говорить о войне | Что случилось (English subtitles)

Тайны ядра Windows: Переполнение буфера, структура KPCR, EPROCESS и защита SMEP.

Тайны ядра Windows: Переполнение буфера, структура KPCR, EPROCESS и защита SMEP.

Я Построил Молот Высокого Давления

Я Построил Молот Высокого Давления

Код работает в 100 раз медленнее из-за ложного разделения ресурсов.

Код работает в 100 раз медленнее из-за ложного разделения ресурсов.

Слышал, их ПРОКАЧАЛИ!💪 POCO M8 PRO и POCO M8 - расскажу ПРАВДУ

Слышал, их ПРОКАЧАЛИ!💪 POCO M8 PRO и POCO M8 - расскажу ПРАВДУ

Microsoft begs for mercy

Microsoft begs for mercy

Упражнение LeetCode на Java — Самая длинная подстрока без повторяющихся символов — БЫСТРОЕ решение

Упражнение LeetCode на Java — Самая длинная подстрока без повторяющихся символов — БЫСТРОЕ решение

Трагедия в Минске / Лукашенко переживает: что случилось

Трагедия в Минске / Лукашенко переживает: что случилось

Absolute Difference Between K Elements | Java solution (3783)

Absolute Difference Between K Elements | Java solution (3783)

Windows Is Dying..

Windows Is Dying..

ДАМПЫ В JAVA на практике, разбираем проблемы

ДАМПЫ В JAVA на практике, разбираем проблемы

Почему простые числа образуют эти спирали? | Теорема Дирихле и пи-аппроксимации

Почему простые числа образуют эти спирали? | Теорема Дирихле и пи-аппроксимации

I Read Honey's Source Code

I Read Honey's Source Code

An intuitive approach to Floyd's Cycle Detection Algorithm (Tortoise and Hare)

An intuitive approach to Floyd's Cycle Detection Algorithm (Tortoise and Hare)

КАЛАШНИКОВ: ТЕПЕРЬ УЖЕ И С МЕНЯ ВСЕ СМЕЮТСЯ❗

КАЛАШНИКОВ: ТЕПЕРЬ УЖЕ И С МЕНЯ ВСЕ СМЕЮТСЯ❗

Как делить на НОЛЬ // Vital Math

Как делить на НОЛЬ // Vital Math

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com