Almost all that this code do is organizing input and output except only this line: count=Collections.frequency(list,x);
This is the only line where real computations happen. Actually, it’s time and space complexity is determined by the standard java.util.Collections.frequency method which should have pretty good time and space characteristics for such a trivial case.
1
solved How can i reduce the time complexity of this program?