Advertisement
Ruhan_DIU

Diamond and sands-URI Problem

Oct 18th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Scanner;
  5.  
  6. //import java.io.File;
  7.  
  8. import static sun.nio.ch.IOStatus.EOF;
  9.  
  10. public class Main {
  11.  
  12. public static void main(String[] args) throws IOException {
  13. Scanner in=new Scanner(System.in);
  14. InputStreamReader es=new InputStreamReader(System.in);
  15. BufferedReader br=new BufferedReader(es);
  16.  
  17. int o=in.nextInt();
  18. for (int y = 0; y <o ; y++) {
  19. String w=in.next();
  20. int count=0;
  21. char[] chars=w.toCharArray();
  22. for (int i = 0; i <chars.length ; i++) {
  23. if(chars[i]=='<'){
  24. for (int j = i; j <chars.length ; j++) {
  25. if(chars[j]=='>'){
  26. count++;
  27. chars[j]='0';
  28. break;
  29. }
  30. }
  31. }
  32. }
  33. System.out.println(count);
  34. }
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement