4th case is failing only in security code couch program | Sololearn: Learn to code for FREE!
0

4th case is failing only in security code couch program

https://code.sololearn.com/cST83V2ZN8wQ/?ref=app

9th May 2020, 3:21 AM
Chetan Singh
Chetan Singh - avatar
7 Answers
+ 2
If you're going to post your code, please save it in the code playground and link to it in your post.
9th May 2020, 3:38 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Remove everything but G, $, and T from the input string. Check remaining string for "$T" or "T
quot; if there output "ALARM" else output "quiet"
9th May 2020, 3:36 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
So here it is half half
9th May 2020, 3:38 AM
Chetan Singh
Chetan Singh - avatar
0
import java.util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String str=sc.nextLine(); int m=str.indexOf('
#x27;); int cg=0,ct=0; char c[]=new char[str.length()]; for(int i=0;i<str.length();i++) { c[i]=str.charAt(i); if(i<m) { if(c[i]=='G') cg=i+1; else if(c[i]=='T') ct=i+1; else { cg=m+1-cg; ct=m+1-ct; if(cg>ct) { System.out.println("ALARM"); break;} else { System.out.println("quiet"); break;} } } cg=str.length(); if(i>m) { if(c[i]=='G') cg=i+1; else if(c[i]=='T') ct=i+1; if(i==st
9th May 2020, 3:37 AM
Chetan Singh
Chetan Singh - avatar
0
Bro my code is not fiitting here
9th May 2020, 3:37 AM
Chetan Singh
Chetan Singh - avatar
0
if(i==str.length()-1) { cg=cg-m-1; ct=ct-m-1; if(cg>ct) { System.out.println("ALARM");break;} else { System.out.println("quiet"); break;} } } } } }
9th May 2020, 3:38 AM
Chetan Singh
Chetan Singh - avatar
0
Ok thanks
9th May 2020, 3:39 AM
Chetan Singh
Chetan Singh - avatar