Тёмный

Mid-Level JavaScript Interview - Part 2: Algorithm + Debrief 

Justin Lawrence
Подписаться 1,1 тыс.
Просмотров 1,4 тыс.
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 13   
@fngkarp492
@fngkarp492 11 месяцев назад
here us ny pathetic try to solve that: let str = '0010001010000101'; let startOfTheLongestZeros = 0; let count = 0; let isZerosRow = false; let max = {start:0, count:0}; const strArray = [...str] strArray.forEach((char,index) => { if(char === '1') { if(count > max.count) { max.start = startOfTheLongestZeros; max.count = count; console.log(max) } isZerosRow = false; count = 0; } if(char === '0') { if(!isZerosRow) { startOfTheLongestZeros = index; } isZerosRow = true; count++; } }) strArray.splice(max.start, max.count,Array(max.count).fill('#').join('')) console.log(strArray.join(''));
@justinmlawrence
@justinmlawrence 11 месяцев назад
Awesome!
@pavelelantsev9507
@pavelelantsev9507 10 месяцев назад
const replaceLongest = (str: string) => { const longest = str .split('1') .reduce((item: string, acc: string) => acc.length > item.length ? acc : item ); const replacer = longest.replaceAll('0', '#'); return str.replaceAll(longest, replacer); };
@danielwilliams487
@danielwilliams487 4 месяца назад
I like it.
@stevenh6294
@stevenh6294 Год назад
I had a go in PHP (my main language). It works. function replaceLongestZeroSubset($input) { $group_key = $max_zeros = $grouping = 0; $previous = $output = ''; $zero_groupings = explode('1', $input); foreach ($zero_groupings as $key => $value) { if (strlen($value) > $max_zeros) { $group_key = $key; $max_zeros = strlen($value); } } $numbers = str_split($input); foreach ($numbers as $key => $value) { if ($previous == 1 && $value == 0) { $grouping++; } ($grouping == $group_key && $value != 1) ? $output .= '#' : $output .= $value; $previous = $value; } return $output; } echo replaceLongestZeroSubset('00100010100101');
@justinmlawrence
@justinmlawrence Год назад
Awesome!! 👏🏻
@Tyheir
@Tyheir Год назад
How do I do one I wanna embarrass myself. 😂
@justinmlawrence
@justinmlawrence Год назад
Join our Discord server to do one! discord.gg/qp9MtuVy
@Pendyala-sharath
@Pendyala-sharath Год назад
What is his VS code theme? 😅
@justinmlawrence
@justinmlawrence Год назад
Michaels’s theme: marketplace.visualstudio.com/items?itemName=divola.ayu-dark-lighter
@laskyb4275
@laskyb4275 Год назад
i'm not good at programming and i'm unemployed cause i usually fail this tests 🤣 this is how i solved it but probably my bigO is so bad i looped like 4 or 5 times const longestZeroSeq = (zerosSeq) => { let zeroHolder = ""; let longest = 0; zerosSeq.split("").forEach((number) => { zeroHolder = number == 0 ? zeroHolder + "0" : ""; if (zeroHolder.length > longest) longest = zeroHolder.length; }); return zerosSeq.replace("0".repeat(longest), "#".repeat(longest)); }; console.log(longestZeroSeq("00100010100101")); //001###10100101
@justinmlawrence
@justinmlawrence Год назад
Awesome!!
Далее
Mid-Level JavaScript Interview
1:19:33
Просмотров 6 тыс.
FATAL CHASE 😳 😳
00:19
Просмотров 1,5 млн
Шоколадная девочка
00:23
Просмотров 189 тыс.
Qalpoq - Amakivachcha (hajviy ko'rsatuv)
41:44
Просмотров 360 тыс.
Mid-Level JavaScript Interview - Part 1: Verbal
14:10
Просмотров 1,1 тыс.
How to prepare your Frontend System Design Interview
13:21
Mid-level React Interview
46:08
Просмотров 66 тыс.
5 Essential JavaScript Interview Questions
20:32
Просмотров 91 тыс.
Junior React Interview - Part 1: Verbal
12:56