Valid Triangle Number | Leetcode 611 | Live Coding session 🔺🔺🔺

preview_player
Показать описание
Here is the solution to "Valid Triangle Number" leetcode question. Hope you have a great time going through it.

Chapters
1) 0:00 Explaining the problem out loud
2) 1:10 Question walkthrough
3) 2:30 Algorithm
5) 8:00 Coding it up

For discussion/feedback

PS : Please increase the speed to 1.25X
Рекомендации по теме
Комментарии
Автор

@10:31, at line no. 13 of your code, you forget to explain the dry run for right--(decrementing right just after adding (right-left) to ans.) By the way good explanation.

Suggestions: can you please explain intuition/observation behing the optimal approach, So it can develop our thought process.

rohan
Автор

My extra like to clear the Intuition behind this problem -> Actually, I faced a problem why R-L gives me right occurrences now I got it.
For someone who wants to know the reference: since we sort the elements so if nums[L] + nums[R] gives me one right answer then all elements between L and R are able to provide me the answer that's why count += R-L -> Hope this makes sense

abhishekvishwakarma
Автор

pretty tricky for optimal answer, ....nice work bro!!

subhamtripathi
Автор

this makes a lot more sense now. Thanks, man.

sakshamsrivastava
Автор

This one is tricky! Thanks for the great explanation!

shrimpo
Автор

Please write down things a little bit more clearly while giving a dry run of your algorithm..it would be very helpful.

mansiverma
Автор

clean explanation, thanks a lot buddy

jaatharsh
Автор

i have taken left equals to i+1 and right=n-1 I am not getting correct answer

ShivamKhantwal
Автор

O(1) Space complexity? Does sorting the array asymptotically affect runtime?

j-espresso
Автор

When calculating the time complexity, isn't the sorting complexity(O(nlogn) taken into consideration?

jancoder
Автор

i have one request can you write this coding in c language ..
i will be very thankful to u please help

princijaiswal
Автор

it's great solution. Thank you . But I have an doubt "we are sorting an array which is going to take (nlogn) time complexity. how come TC becomes o(n2) ? isn't sorting going to take additional time ?

praveenj
join shbcf.ru