Let, the number of balls on one side of the equilateral triangle is n, then the number of balls on each side of the square will be n−2.
Then, total balls used in the triangle are 1+2+3+...+n
Now, the sum of first n natural numbers is 1+2+3+...+n=2n(n+1)
And, the total balls used in the square is (n−2)+(n−2)+(n−2)+....(n−2)times=(n−2)2
From the given condition we can write
2n(n+1)+99=(n−2)2
⇒n(n+1)+198=2(n2−4n+4)
⇒n2−9n−190=0
⇒(n−19)(n+10)=0
⇒n=19 or n=−10, neglected as n is the number of balls and hence, it can't be negative.
Hence, number of balls in equilateral triangle
=2n(n+1)=219⋅20=190.