Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Doing a coding challenge LIVE: Zigzag Conversion!

  • KG.codes
  • 2025-09-02
  • 2455
Doing a coding challenge LIVE: Zigzag Conversion!
  • ok logo

Скачать Doing a coding challenge LIVE: Zigzag Conversion! бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Doing a coding challenge LIVE: Zigzag Conversion! или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

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

Cкачать музыку Doing a coding challenge LIVE: Zigzag Conversion! бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Doing a coding challenge LIVE: Zigzag Conversion!

Here is the problem and solution to a coding challenge from Leetcode.com called Zigzag Conversion!

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this:
P A H N
A P L S I I G
Y I R
The new version of the string is read line by line: "PAHNAPLSIIGYIR"

Write the code that will take a string and make this conversion given a number of rows.
Example
Input: string = "PAYPALISHIRING", numRows = 3
Output: "PAHNAPLSIIGYIR"

Intuition / tip:
Simulate writing characters in a zigzag by keeping track of the current row and the direction (down or up, zig or zag). Each character goes into the right row, and when you hit the top or bottom, you flip the direction (zig or zag).

Solution steps:
Handle the base case: if numRows is 1 (or the string is too short), just return the string.
Create an array of arrays “rows” variable, which each row being an empty array to collect characters.
Create a boolean variable “isZig” to store whether the current direction is zig or zag (up or down).
Create a int variable “currentRow” to storage the current row.
Loop over the string’s characters one-by-one..
(..inside the loop) Push the current character into the current row’s array
(..inside the loop) If you’re at the top (currentRow equal to 0), set isZig to true (zig/down); if you’re at the bottom (currentRow equal to numRows - 1), set isZig to false (zag/up).
(..inside the loop) If isZig is true, them increment currentRow index, else (isZig is false) decrement it.
After finishing the loop of the string, join all row arrays into strings, then join them together for the final result.

Time complexity:
O(n) - every character is visited once and added to a row, and then all rows are joined back together.

Space complexity:
O(n) - extra space is needed to store all characters across row arrays before joining them into the final string.

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

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/...

Комментарии

Информация по комментариям в разработке

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

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

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