Популярное

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

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

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

Топ запросов

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

Leetcode 3170 | Lexicographically Minimum String After Removing Stars | Priority Queue Java Solution

Автор: codingX krishna

Загружено: 2025-06-06

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

Описание:

In this video, we solve Leetcode Problem 3170 - Lexicographically Minimum String After Removing Stars using a greedy approach with a priority queue in Java.

🔹 Problem Summary:
You're given a string s made up of lowercase letters and '*' characters.
Each time a '*' is encountered, you must remove the lexicographically smallest character that appears before it.
Your task is to return the final string after applying all '*' operations.

🔹 Approach:

Use a priority queue (min-heap) to always get the smallest character seen so far.

Maintain character indices in the heap to track what gets removed.

When a '*' is found, remove the smallest character from the heap and mark it using a boolean array.

In the end, rebuild the string by skipping removed characters and all '*'.

🧠 Time Complexity:

O(n log n) — Each insert/remove operation in the priority queue takes log n, and we can have up to n such operations.

🧠 Space Complexity:

O(n) — For the priority queue and the isRemoved array.

Leetcode 3170 | Lexicographically Minimum String After Removing Stars | Priority Queue Java Solution

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

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

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

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

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

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

array(0) { }

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



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



Контакты для правообладателей: [email protected]