3576. Transform Array to All Equal Elements | Array | Greedy | Leetcode

preview_player
Показать описание
3576. Transform Array to All Equal Elements | Array | Greedy | Leetcode

In this video, I'll talk about how to solve Leetcode 3576. Transform Array to All Equal Elements

Let's Connect:

Resources you can try:

🎥Channel Playlists

Channel Description:
Hey, I'm Priyanshi Agarwal, Software Engineer at Amazon who loves turning free time into productive moments. On my channel, we're all about cool coding and getting better in life. Let's hang out, learn some code, and grow together! 🚀

#programming #Interviews #leetcode #faang #maang #datastructures #algorithms #leetcodedailychallenge #Rapidsyntax #RapidSyntax
Рекомендации по теме
Комментарии
Автор

Dii, How did you think of that approch
I tried, actually the approach which came in my mind was
going from smallest
like for n = 1 it will always return true
for n = 2
1 1
- 1 -1
1 -1
-1 1
if both are same then only true else false
for n = 3
1 1 1
-1 -1 -1
1 -1 1
-1 1 1
in all the cases we can convert it to same values
hence n = 3 will always return false

after that I was unable to think of!

MAYANK-IIT-D
Автор

Yea true, even in contest i knew we can do this. But i have been doing dp and recursion for some time now.
I am still confused on how greedy approach is better. that to going from left to right.
Could you also provide some proof that greedy that is left to right is better.
After they mentioned K right. I got this doubt.
Q2 was easy and solved under 10min.
But Q1 no..I was tryinh to figure out if greedy was better or random pick in between provided a better result.
Because lets say left to right greedy gave a false for K. Is there any proof that random pick will also give false.
Anyway the solution is too damn easy and straight forward.

VictorySk-nc
Автор

Mam how u get this approch .. because i was stucked more than 30 mins to get any clue..

ravitiwari
Автор

mam what to do if we cant think of the problem intuitively??...please guide me how can i get better as a beginner..right now i am doing blind 75 problems but how do i solve problems which have a new approach in them like this..pls guide me as beginner in leetcode how can i improve myself

viveklamba
join shbcf.ru