I am getting TLE for 3 T.Cases .
ques link : problem
my soln link : my soln.
can you suggest me how to remove TLE , by using brute force method
How to remove TLE?
@army_100 the approach you used to solve the problem is not correct.The probelm says you have to find that element which is greater than floor(n/3) so for this case
8
2 2 3 1 3 2 1 1
floor(n/3) = 2
so clearly we can see frequency of 1 & 2 are greater than 2 so the o/p will be
1 2
but your code produces output as only 2.
and it is said to do in O(n) but you are using two loops.
you check out this video in the first part this question is explained very well.If still you have doubt post it here.