Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Created April 27, 2020 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ereshzealous/02518124966aeb45d7ab6c86cd99837e to your computer and use it in GitHub Desktop.
Save ereshzealous/02518124966aeb45d7ab6c86cd99837e to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class HelpJarvis {
public final static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int kb = 1024;
int numberOfCases = 5000;
List<String> list = new ArrayList<>();
for (int i = 0; i < numberOfCases; i++) {
String data = "03333";
char[] chars = data.toCharArray();
Arrays.sort(chars);
boolean series = true;
for (int index = 0; index < chars.length-1; index++) {
if (chars[index + 1] - chars[index] != 1) {
series = false;
System.out.println("NO");
break;
}
}
if (series) {
System.out.println("YES");
}
}
System.out.println("Total Memory in (KB)" + (double) Runtime.getRuntime().totalMemory()/ kb);
System.out.println("Actual Memory in (KB): " + (double) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / kb);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment