Тёмный

Missing Coin Sum CSES - explained and solved completely in HINDI 

Deepak Joshi
Подписаться 339
Просмотров 2,4 тыс.
50% 1

You have n coins with positive integer values. What is the smallest sum you cannot create using a subset of the coins?
Input
The first input line has an integer n: the number of coins.
The second line has n integers x1,x2,…,xn: the value of each coin.
Output
Print one integer: the smallest coin sum.
Constraints
1≤n≤2⋅105
1≤xi≤109
Example
Input:
5
2 9 1 2 7
Output:
6

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

 

27 мар 2022

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 9   
@akgpian
@akgpian 5 месяцев назад
Still not getting the intuition of doing this logic
@krishnasoni-ge2cx
@krishnasoni-ge2cx Год назад
what is the intution behind this?
@arindamthakur166
@arindamthakur166 Год назад
lol
@rtn3756
@rtn3756 2 года назад
Thank u so much , it was a nice explanation , can you please tell me how changing it to long long made the difference in output
@deepak_joshi_the_conqurer_
@deepak_joshi_the_conqurer_ 2 года назад
As the output was out of the range of int ( that is 2147483647 ) , so we used long long instead of int!! (Sorry for replying late.)
@trickydirector2584
@trickydirector2584 Год назад
Hey great video as usual! I was able to dry run the code but i didn't get the intuition behind it, could you explain it
@deepak_joshi_the_conqurer_
@deepak_joshi_the_conqurer_ Год назад
Hey thank you , intution bus brute force thi kuch aisa nhi kiya jo out of the box thinking ho. Aap bus sum le rhe hai elements ka , sum ko kam pate hi aap for loop se bahar ajayenge!! I hope main ish text ke through bata paya hoon. Do you want more videos of cses problem set?
@trickydirector2584
@trickydirector2584 Год назад
@@deepak_joshi_the_conqurer_ I get it now, turns out it was quite intuitive when I tried your logic on multiple test cases! Also yes it would be great if you'd cover more CSES problems!! Btw, i had a few doubts (not related to problem solving), do you have any email id that you'd respond to? That would be of great help!
@deepak_joshi_the_conqurer_
@deepak_joshi_the_conqurer_ Год назад
@@trickydirector2584 deepakjoshicscoder@gmail.com I'm a little lazy to check my emails :)