Skip to content

Instantly share code, notes, and snippets.

@Jack-Saleem
Created July 17, 2016 13:30
Show Gist options
  • Save Jack-Saleem/0bc3eb8cceaafceae3d8da03b75bf3e1 to your computer and use it in GitHub Desktop.
Save Jack-Saleem/0bc3eb8cceaafceae3d8da03b75bf3e1 to your computer and use it in GitHub Desktop.
Codeforces 424A Squats program in java
import java.util.Scanner;
public class Squats
{
public static void main(String[] args)
{
Scanner z=new Scanner(System.in);
short n=z.nextShort();
String x=z.next();
int a=Math.max(x.replaceAll("X", "").length(), x.replaceAll("x", "").length())-n/2;
System.out.println(a);
if(x.replaceAll("X", "").length() >= x.replaceAll("x", "").length()){
for(int i=0;i<a;i++)
x=x.replaceFirst("x", "X");
System.out.println(x);
} else {
for(int i=0;i<a;i++)
x=x.replaceFirst("X", "x");
System.out.println(x);
}z.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment