This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isPalindrome(String str) { | |
if (str == null || str.charAt(0) != str.charAt(str.length() - 1)) { | |
return false; | |
} else if (str.length() <= 1) { | |
return true; | |
} else { | |
return isPalindrome(str.substring(1, str.length() - 1)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class main { | |
public static void main(String args[]){ | |
boolean running = true; | |
while(running){ | |
try{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.lang.Math; | |
class Main { | |
private static int[] count_cache = new int[100000]; | |
public static void main(String args[]) throws Exception { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class Main { | |
public static void main(String args[]) throws Exception { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String line = null; | |
while ((line = br.readLine()) != null) { | |
int n = Integer.parseInt(line); | |
int[] counts = count(1, n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isPangram(String s) { | |
if (s == null || s.length() < 26) { | |
return false; | |
} | |
int[] counts = new int[26]; | |
for (char c : s) { | |
if (Character.isletter(c) { | |
counts[c - 'a']++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.lang.Math; | |
class Main { | |
public static void main(String args[]) throws Exception { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
int cases = Integer.parseInt(br.readLine()); | |
while (cases-- > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pokemon extends Exception { | |
public Pokemon(String message) { | |
super(message); | |
} | |
} | |
class Main { | |
public static void main(String args[]) throws Exception { | |
throw new Pokemon("Gotta Catch 'Em All!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem: | |
You are given a list of tokens which represent a mathematical expression. | |
Write an algorithm that will determine the value of a given mathematical expression. | |
Input: | |
You are given an integer n (1 <= n <= 100000), which represents the number of expressions | |
following. Each expression will be on a line of tokens separated by spaces. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
class Main { | |
public static void main(String args[]) throws IOException { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String line = br.readLine(); | |
int n = Integer.parseInt(line); | |
while (n-- > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
class Bag { | |
private ArrayList<Integer> bag; | |
private int size; | |
public Bag() { | |
this.bag = new ArrayList<Integer>(); | |
this.size = 0; |
OlderNewer