i have used the same logic as in c++ but got tle in my java code i have also used buffered class for faster input.plz help me out from this problem.
Problem https://codeforces.com/contest/1519/problem/C
My submission: https://codeforces.com/contest/1519/submission/167712080
use StringBuilder to store answer