Skip to content

Instantly share code, notes, and snippets.

@baalajimaestro
Created September 1, 2018 12:42
Show Gist options
  • Save baalajimaestro/63183a3920c9d3de7e0ce25df2ca84eb to your computer and use it in GitHub Desktop.
Save baalajimaestro/63183a3920c9d3de7e0ce25df2ca84eb to your computer and use it in GitHub Desktop.
Simple program In java
import java.io.*;
class Nekofuri
{
public static void main(String[] args)throws IOException
{
String str;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
str=br.readLine();
char[] A=str.toCharArray();
char B[]=new char[A.length];
int ctr=1;
char x=A[0];
int i,k=0;
for(i=1;i<A.length;i++)
{
if(x==A[i])
{
ctr++;
}
else if(ctr>=1)
{
if(ctr%2==1)
{
B[k++]=x;
}
ctr=1;
x=A[i];
}
}
if(ctr%2==1)
{
B[k++]=x;
}
System.out.println(B);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment