ycliper

Популярное

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

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

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

Топ запросов

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

Doing a coding challenge LIVE: Longest Palindromic Substring!

Автор: KG.codes

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

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

Описание: Here is the problem and solution to a coding challenge from Leetcode.com called Longest Palindromic Substring!

Given a string s, return the longest palindromic substring in s.
Example
Input: s = "babad"
Output: "bab"
Explanation: "aba" is also a valid answer.

Intuition / tip:
Every palindrome expands outward from its center. By treating each character (and the space between characters) as a possible center, you can grow outward to find the longest odd and even length palindromes.

Solution steps:
1. Initialize the longest palindrome as the first character.
2. Loop through each index in the string as a possible center.
3. Expand outward from the center to find the longest odd-length palindrome.
4. Expand outward from the center and the next index to find the longest even-length palindrome.
5. Compare both results to the current longest palindrome and update if needed.
6. Return the longest palindrome found after all centers are checked.

Time complexity:
O(n²), because for each character in the string, the algorithm may expand across the entire string in the worst case.

Space complexity:
O(1), because only a constant amount of extra space is used regardless of input size.

💬 Comment: Let me know if you have any questions or see ways I could have optimized!

If you found this interesting or helpful, please consider liking, sharing, or saving to support it.

Let's connect!
🌐 Website | https://www.kg.codes
📺 Subscribe |    / @kgcodes  
📷 Instagram | www.instagram.com/kg.codes/
🎵 TikTok | www.tiktok.com/@kg.codes
🐦 Twitter | www.twitter.com/kgcodes/

Get my gear / desk setup / smart home 👨🏾‍💻
📦 Amazon | https://www.amazon.com/shop/kg.codes/...

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Doing a coding challenge LIVE: Longest Palindromic Substring!

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

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

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

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

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

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

Doing a coding challenge LIVE: Valid Parentheses!

Doing a coding challenge LIVE: Valid Parentheses!

Coding Challenge from Leetcode - Valid Parentheses!

Coding Challenge from Leetcode - Valid Parentheses!

Animation vs. Coding

Animation vs. Coding

Data Structure and Algorithm Patterns for LeetCode Interviews – Tutorial

Data Structure and Algorithm Patterns for LeetCode Interviews – Tutorial

Why I quit coding

Why I quit coding

Я наконец понял, как научиться программировать

Я наконец понял, как научиться программировать

System Design Concepts Course and Interview Prep

System Design Concepts Course and Interview Prep

Алгоритмы и структуры данных ФУНДАМЕНТАЛЬНЫЙ КУРС от А до Я. Графы, деревья, хеш таблицы и тд

Алгоритмы и структуры данных ФУНДАМЕНТАЛЬНЫЙ КУРС от А до Я. Графы, деревья, хеш таблицы и тд

Я составил рейтинг всех карьерных путей в сфере технологий (Кто победит в 2026 году?)

Я составил рейтинг всех карьерных путей в сфере технологий (Кто победит в 2026 году?)

Как учиться быстро и самому? На примере языков  программирования.

Как учиться быстро и самому? На примере языков программирования.

Programming Party Tricks

Programming Party Tricks

JavaScript - Полный Курс JavaScript Для Начинающих [11 ЧАСОВ]

JavaScript - Полный Курс JavaScript Для Начинающих [11 ЧАСОВ]

Программирование будет трудным, пока вы этому не научитесь

Программирование будет трудным, пока вы этому не научитесь

Почему работает теория шести рукопожатий? [Veritasium]

Почему работает теория шести рукопожатий? [Veritasium]

Алгоритмы на Python 3. Лекция №1

Алгоритмы на Python 3. Лекция №1

How I Approach a New Leetcode Problem (live problem solving)

How I Approach a New Leetcode Problem (live problem solving)

Алгоритмы и структуры данных за 15 минут! Вместо 4 лет универа

Алгоритмы и структуры данных за 15 минут! Вместо 4 лет универа

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

ВОТ ЧТО РЕАЛЬНО БУДЕТ С ИНТЕРНЕТОМ В РОССИИ: Белые списки, конец Wi-Fi, Вход по паспорту.

ВОТ ЧТО РЕАЛЬНО БУДЕТ С ИНТЕРНЕТОМ В РОССИИ: Белые списки, конец Wi-Fi, Вход по паспорту.

But what is quantum computing?  (Grover's Algorithm)

But what is quantum computing? (Grover's Algorithm)

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



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



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