-
-
Save zaidw21/c418d2c479d3927855200e1ff4974c05 to your computer and use it in GitHub Desktop.
a |
import java.util.Scanner;
public class Solution {
private static int[] frequency = new int[26];
static boolean isAnagram(String a, String b) {
a = a.toLowerCase();
b = b.toLowerCase();
for (char c : a.toCharArray()) {
frequency[(int) c - 97]++;
}
for (char c : b.toCharArray()) {
frequency[(int) c - 97]--;
}
boolean anagrams = true;
for (int i : frequency) {
if (i != 0) {
anagrams = false;
break;
}
}
return anagrams;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String a = scan.next();
String b = scan.next();
scan.close();
boolean ret = isAnagram(a, b);
System.out.println( (ret) ? "Anagrams" : "Not Anagrams" );
}
}
import java.io.;
import java.util.;
import java.text.;
import java.math.;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
BigInteger n = in.nextBigInteger();
in.close();
if(n.isProbablePrime(1)){
System.out.println("prime");
}
else{
System.out.println("not prime");
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
//Complete the classes below
class Flower {
private String message;
public Flower(String message) {
this.message = message;
}
public Flower() {
this("I have many names and types");
}
String whatsYourName() {
return this.message;
}
}
class Jasmine extends Flower {
public Jasmine() {
super("Jasmine");
}
}
class Lotus extends Flower {
public Lotus() {
super("Lotus");
}
}
class Lily extends Flower {
public Lily() {
super("Lily");
}
}
class Region {
Flower yourNationalFlower() {
return new Flower();
}
}
class WestBengal extends Region {
@OverRide
Jasmine yourNationalFlower() {
return new Jasmine();
}
}
class Karnataka extends Region {
@OverRide
Lotus yourNationalFlower() {
return new Lotus();
}
}
class AndhraPradesh extends Region {
@OverRide
Lily yourNationalFlower() {
return new Lily();
}
}
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine().trim();
Region region = null;
switch (s) {
case "WestBengal":
region = new WestBengal();
break;
case "AndhraPradesh":
region = new AndhraPradesh();
break;
}
Flower flower = region.yourNationalFlower();
System.out.println(flower.whatsYourName());
}
}
Food food = null;
if ("pizza".equals(order))
food = new Pizza();
else if ("cake".equals(order))
food = new Cake();
return food;