Skip to content

Instantly share code, notes, and snippets.

@mizushou
Created November 19, 2017 20:27
Show Gist options
  • Save mizushou/caa72bb990697a827895fbee681af39a to your computer and use it in GitHub Desktop.
Save mizushou/caa72bb990697a827895fbee681af39a to your computer and use it in GitHub Desktop.
Good Integerの別解。こちらはより一般的な解法。4桁に限らず判定できる。
import java.util.Scanner;
class GoodInterger2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char[] c = sc.next().toCharArray();
sc.close();
for(int i=0; i<c.length; i++){
int j = i;
while(j<c.length) {
if(c[i] != c[j]) break;
j++;
}
if(j -i >=3) {
System.out.println("Yes");
return;
}
};
System.out.println("No");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment