Тёмный

3068. Find the Maximum Sum of Node Values - Day 20/31 Leetcode May Challenge 

Programming Live with Larry
Подписаться 31 тыс.
Просмотров 907
50% 1

Larry solves and analyzes this Leetcode problem as both an interviewer and an interviewee. This is a live recording of a real engineer solving a problem live - no cuts or edits!
Problem: leetcode.com/problems/find-th...
Twitch: / larryny
Discord: / discord
Instagram: / larrysomewhere
#leetcode #coding #programming

Наука

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

 

17 май 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 13   
@Algorithmist
@Algorithmist Месяц назад
Were you able to get all the node values?
@user-vs3jn4xi4x
@user-vs3jn4xi4x Месяц назад
nopes i found it hard but i will try later lets just like the vid first will try by my own first.
@erminiottone
@erminiottone Месяц назад
Nope :(
@erminiottone
@erminiottone Месяц назад
I'm at day 142 of my streak. The last few days I feel that I have lost strength/will and have little energy. I feel that I concentrate less when I start to solve a problem and give up more easily. I felt I gave up to problems that I could probably solve if I was less burned out. Has this ever happened to you?
@vanchark
@vanchark Месяц назад
I was working out this problem on paper and realized that xor'ing [a,b] then xor'ing [b,c] is essentially the same as xor'ing [a,c], but for some reason I couldn't quite realize that you just need to select the "best" pairs to xor. But your video made it so clear, thank you!
@karanmehta2890
@karanmehta2890 Месяц назад
I can solve 3 problems every contest but always either struggle badly with 4th or run out of time. What do you suggest?
@Algorithmist
@Algorithmist Месяц назад
I talk about it here - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dDEneqyWsI4.html but really it's just more practice, but trying to do it deliberately
@rohitkumarpilania94
@rohitkumarpilania94 Месяц назад
After today's contest i am taking a break from Coding for a week, too burnt out to even solve Q2
@Algorithmist
@Algorithmist Месяц назад
It's okay to take time off!
@adityavats3990
@adityavats3990 Месяц назад
There is another way...keeping track of xor done odd times or even times....at the end consider even times xor ...Maintain a DP for the same.. TC O(n) SC O(n)
@user-cy6dv3ks3y
@user-cy6dv3ks3y Месяц назад
we can even optimise to O(n) time and SC O(1) space by optimising space in dp
@user-vs3jn4xi4x
@user-vs3jn4xi4x Месяц назад
or simply also keeping the track for the minimum addition that we were able to do by the xor operation i.e min = Math.min(min,num^k-num) this way if at the end the count says that there were odd number of xors we could just subtract min from our total sum! This isn't mine i saw at as the solution after realising oh this was done in 1ms runtime! Simply beautiful TC O(n) SC(1)
@zweitekonto9654
@zweitekonto9654 Месяц назад
What if we apply dp on edges, like we have a set of edges, we have 2 choices either we choose or drop the edge... and every time we choose we update the corresponding nodes and recurse again.
Далее
How to Start Leetcode in 2024 (as a beginner)
8:45
Просмотров 695 тыс.
Он тоже из IKEA 🙀
00:10
Просмотров 265 тыс.
Жидкие носки)))
00:19
Просмотров 861 тыс.
Are headphones destroying our hearing?
6:49
Просмотров 390 тыс.
A Simpler Way to See Results
19:17
Просмотров 97 тыс.
Купил этот ваш VR.
37:21
Просмотров 297 тыс.
ДЕШЕВЫЙ НОУТБУК C OZON ЗА 17000р
13:00