Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

HOLES problem

$
0
0

here is my code for the holes problem..its showing WA..dont know why..

import java.util.Scanner; import java.io.*; class HOLES { static InputStreamReader isr=new InputStreamReader(System.in); static BufferedReader br=new BufferedReader(isr); // A B-2 D O P Q R public static void main(String args[]) { Scanner input=new Scanner(System.in); int count,i,j,len,t; //System.out.println("Enter the number of test cases"); try { t=input.nextInt(); while(t>0) //for(i=1;i<=t;i++) {

//System.out.println("enter the text"); String s=br.readLine();

count=0; len=s.length(); if(len>=100) len=99; for(i=0;i<len;i++) { if((s.charAt(i)=='A') || (s.charAt(i)=='D') || (s.charAt(i)=='O') || (s.charAt(i)=='P') || (s.charAt(i)=='Q') || (s.charAt(i)=='R')) { count++; } else if(s.charAt(i)=='B') { count=count+2; } else { continue; } } System.out.println(count); t--; } } catch(Exception e) { System.err.println(e); } } }


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>