Тёмный

Find if N people can vote on 2 machines : step by step explanation with intuition 

Joey'sTech
Подписаться 4,1 тыс.
Просмотров 204
50% 1

When you practicing the DP problems for beginners then you will find 01 Knapsack problem as one of the highlighted problems in the pool.
Let me tell you that when you are going to learn the 01 knapsack problem (link provided below) you will find it interesting and you will see it as a
magical way to solve a problem which is in the foundation of many computing problems.
Any dynamic programming tutorial is incomplete without the 0/1 knapsack problem. But understanding the knapsack problem is an easy deal.
The complexity begins when you have to implement it to solve the dynamic programming problems based on it.
When you are preparing dynamic programming for coding interviews then practicing questions which are based on popular DP problems is required.
Joey tries to bring for you such dynamic programming examples which are spin-offs of the existing dynamic programming problems like Knapsack problem.
This DP problem is based on the 01 knapsack problem. The plot of this problem is intriguing and it is evident from its title only.
'Check if all people can vote on 2 voting machines'
So, what does this problem says?
Let's understand the problem in following steps-
There N people in line to vote.
There are 2 voting machines available. These machines will only be up and running for X minutes.
If the ith person takes a[i] minutes to vote, then you need to find out if all people can vote on 2 machines within the time X.
Here's the data -
N=3
X= 5 mins
A = 2,5,3
So, there are 3 people to vote. P1 takes 2 mins, P2 takes 5 mins and P3 takes 3 mins.
To design the dynamic programming algorithm of this DP problem, you must watch this video of Joey'sTech till the end.

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

 

21 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 4   
@shuvabhigupta976
@shuvabhigupta976 3 года назад
Best explaintion I have seen for this type of problem . Thank you for making such tutorials.
@joeystechpluscode
@joeystechpluscode 3 года назад
So nice of you
@ahsanamin3818
@ahsanamin3818 3 года назад
Is there number of voting machine is always constant?
@joeystechpluscode
@joeystechpluscode 3 года назад
Yes, in the problem statement it is mentioned 2 machines :)
Далее
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 810 тыс.
These Are Too Smooth 😮‍💨
00:57
Просмотров 3,8 млн
How to get skins for FREE? #standoff #skins #coins
00:34
ML Was Hard Until I Learned These 5 Secrets!
13:11
Просмотров 327 тыс.
C++ vs Rust: which is faster?
21:15
Просмотров 399 тыс.
Simple Explanation of the Birthday Paradox
12:11
Просмотров 13 тыс.
I reverse engineered Next to find what they are hiding
29:48
Think Fast, Talk Smart: Communication Techniques
58:20
Game Theory
1:07:08
Просмотров 514 тыс.
AES: How to Design Secure Encryption
15:37
Просмотров 166 тыс.
How To Think Like A Programmer
1:00:07
Просмотров 2 млн