Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Consecutive Elements String
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.io.*; import java.util.*; import java.lang.*; class Rextester { public static void main (String[] args) throws IOException { //code BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0){ String str = br.readLine(); StringBuilder sb = new StringBuilder(); sb.append(str.charAt(0)); for(int i=1;i<str.length();i++){ if(str.charAt(i-1)==str.charAt(i)) continue; else sb.append(str.charAt(i)); } System.out.println(sb.toString()); } } }
run
|
edit
|
history
|
help
0
OBF-7 4
epeenconverter
Switch case example
predecrement
Leetcode 297. Serialize and Deserialize Binary Tree
Multiples of 3 and 5
HelloUser
default constructor
LambdaExpression
Random and count of even numbers