fork download
  1. import java.util.*;
  2. import java.io.*;
  3. public class Main
  4. {
  5. public static void main(String args[]) throws IOException
  6. {
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. int t = sc.nextInt();
  10. char a[] = new char[1000005];
  11.  
  12.  
  13. while(t-- > 0)
  14. {
  15. int length = br.read(a);
  16. int x=0,i=0,ans=0;
  17.  
  18. for(i=0 ; i<length ; i++)
  19. {
  20. if(a[i] == '<')
  21. x++;
  22. else
  23. x--;
  24. if(x<0)
  25. break;
  26. if(x==0)
  27. ans=i+1;
  28. }
  29. System.out.println(ans);
  30. }
  31. }
  32. }
Success #stdin #stdout 0.1s 380608KB
stdin
3
<<>>
><
<>>>
stdout
0
0
0