Тёмный

Codility's MaxCounters Coding Interview - Part 4 

James Cutajar
Подписаться 13 тыс.
Просмотров 2,1 тыс.
50% 1

Coding interview here: app.codility.c...
Problem from the Counting Elements section.
Please support me through my Udemy courses:
Pass your coding interview in,
Java : www.udemy.com/...
Python: www.udemy.com/...
Ruby: www.udemy.com/...
JavaScript: www.udemy.com/...
Multithreading in,
Go Lang: www.udemy.com/...
Python: www.udemy.com/...
Java: www.udemy.com/...
Learn Dynamic Programming in,
Java: www.udemy.com/...
Python: www.udemy.com/...
Ruby: www.udemy.com/...
Blog: www.cutajarjame...

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

 

9 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 3   
@rzezol
@rzezol Месяц назад
If anybody is looking for performant solution with caching max value (not applying it every time we encounter "max counter" operation - it's very time consuming) there you have it: vector solution(int N, vector &A) { std::vector counters(N, 0); int max_val = 0; bool apply_max = false; for (int operation : A) { if (operation max_val) { max_val = cur_val; apply_max = true; } } else { if (apply_max) { std::fill(counters.begin(), counters.end(), max_val); apply_max = false; } } } return counters; }
@CyberMew
@CyberMew 3 года назад
I still don't get it. How would this work and what's the rationale for it? What's the intuition for this? Update: nvm I found out part 3. Basically idea is that when the time comes, we 'save' the 'column' they are all supposed to be in (i.e. the leading/furthest position) and update those who are below the 'column' later, AFTER everything is done. Otherwise those after the 'column' should proceed as per normal. This works because it doesn't matter the positions before the 'column' as we don't care about it.
@scrapz000
@scrapz000 3 года назад
clear explanation great video, patiently waiting for the next video :)
Далее
Codility's MaxCounters Coding Interview - Part 1
5:05
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Cute
00:16
Просмотров 2,5 млн
5 Simple Steps for Solving Any Recursive Problem
21:03
Codility's MaxCounters Coding Interview - Part 2
4:04
Просмотров 3,6 тыс.
Google Coding Interview With A High School Student
57:24
Codility Max Counters Java solution
26:54
Просмотров 8 тыс.
Winning Facebook (Meta) Hacker Cup Qual Round 2022?
53:55
Coding Interview Workshop
1:11:20
Просмотров 6 тыс.
Coding Interview: Find K Closest Elements
19:14
Просмотров 3,6 тыс.
Google Coding Interview With A Competitive Programmer
54:17
Apache Kafka in 6 minutes
6:48
Просмотров 1 млн