Counting Triangles Coding Question #InterviewBit Code+Explanation+Example

preview_player
Показать описание
You are given an array of N non-negative integers, A0, A1 ,…, AN-1.

Considering each array element Ai as the edge length of some line segment, count the number of triangles which you can form using these array values.

Notes:

You can use any value only once while forming each triangle. Order of choosing the edge lengths doesn’t matter. Any triangle formed should have a positive area.

Return answer modulo 109 + 7.

For example,

A = [1, 1, 1, 2, 2]

Return: 4
Рекомендации по теме
Комментарии
Автор

that was a great explanation, thanks a lot !

intratec
Автор

you are really a very very good explainer whatever u explain u code exactly that which helps us to understand more easily.

devanshdixitmusicallyyours
Автор

Thanks a lot dii for such a nice explanation.

Aman-wumb
Автор

Subscribed to you with my two accounts . Your explanation is top notch

rockyjoe
Автор

Thank you so much for amazingly explaining the solution.

SomneelMaity
Автор

Hello di great explanation, but the solution is O(n^2). And it is given that n can be as large as 10^5. Don't you think the solution should have failed?

atanunayak
Автор

did aproach appko pehle se pata thi ya app ko question dekhke samjh aagayi

showsshorts
join shbcf.ru