Leetcode - Valid Triangle Number (Python)

preview_player
Показать описание
July 2021 Leetcode Challenge
Leetcode - Valid Triangle Number #611
Difficulty: Medium
Рекомендации по теме
Комментарии
Автор

I love your youtube profile: "Living the Data Lyfe, it aint glamorous, it's tedious. I love it."
Too honest 😂 yet an accurate representation of one's feeling

nathanjeong
Автор

not sure I understand this:
If we found a {i, j, k} such that i + j > k, then you add the whole range of possible j1 = {i:j} to result. But any such j1 < j, so where is the guarantee that i + j1 > k?
Consider [1, 1, 1, 1, 10, 10], i = 1, k = 10, j = 10. 1-10-10 works, but any other j for the same {i, k} does not - 1-1-10 does not form a triangle. Yet it looks like you would count 4 triangles for this {i, j k}.
Also notice that i=1, j = 1, k = 1 all work, so we would have counted them before, and then we count them again for 1-10-10?

AlexN
join shbcf.ru