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.math.BigDecimal; | |
import java.math.MathContext; | |
public class EulersNumber { | |
public static void main(String[] args) { | |
BigDecimal e = BigDecimal.ONE; | |
BigDecimal bigDecimal = BigDecimal.ONE; | |
for(int i=1;i<100;i++) { | |
bigDecimal = bigDecimal.multiply(new BigDecimal(i * 1.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; | |
import java.io.*; | |
public class AlienLanguage { | |
public int checkPattern(ArrayList wordsAL, String pattern) { | |
int res = 0; | |
for(int i=0;i<wordsAL.size();i++) { | |
if(((String) wordsAL.get(i)).matches(pattern.replaceAll("[(]","[").replaceAll("[)]","]"))) res++; | |
} |
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.*; | |
import java.io.*; | |
public class Magicka { | |
public String castAspell(HashMap<String, String> mergeMap, HashMap<String, ArrayList<String>> opposingMap, | |
String invokeString, int invokeStringLength) { | |
StringBuilder sbOutput = new StringBuilder("" + invokeString.charAt(0)); | |
for(int i=1;i<invokeStringLength;i++) { | |
int len = sbOutput.length(); |
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 class SnapperChain { | |
private String findDeviceStatus(double numOfSnappers, double numOfSnaps) { | |
if(numOfSnaps == 0) return "OFF"; | |
double minRequiredSnaps = Math.pow(2, numOfSnappers) - 1; | |
if(numOfSnaps < minRequiredSnaps) return "OFF"; | |
return (minRequiredSnaps == numOfSnaps || ((numOfSnaps % (minRequiredSnaps + 1)) == minRequiredSnaps)) ? "ON" : "OFF"; | |
} | |
} |
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.HashMap; | |
/** | |
* | |
* @author Babji Prashanth, Chetty | |
*/ | |
public class GoogleRese { | |
public String translate(String input) { | |
HashMap<Character, Character> dict = getDictionary(); | |
StringBuilder sbTranslatedPhrase = new StringBuilder(); |
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.*; | |
import java.io.*; | |
public class BotTrust { | |
private int findMin(String inputLine) { | |
int index = 0; | |
String[] splitString = inputLine.split(" "); | |
int n = Integer.parseInt(splitString[index++]); | |
Queue<String> orderQueue = new LinkedList<String>(); | |
Deque<Integer> orangeQueue = new ArrayDeque<Integer>(); |
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.*; | |
import java.math.BigInteger; | |
public class FairWarning { | |
public BigInteger nextApocalypseParty(int n, ArrayList<BigInteger> numberList) { | |
Collections.sort(numberList); | |
BigInteger smallest = numberList.get(0); | |
BigInteger gcdBigInt = new BigInteger("0"); | |
for(int i=1;i<n;i++) { |
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.*; | |
import java.io.*; | |
public class OddManOut { | |
public String getTheOddOneOut(String lineWithNumbers, int numberCount) { | |
String[] numberArr = lineWithNumbers.split("[ ]"); | |
Arrays.sort(numberArr); | |
ArrayList<string> list1 = new ArrayList<string>(); | |
for(int index=0;index<numberCount;index++) { |
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 class MinimumScalarProduct { | |
public BigInteger findMin(String strXArr, String strYArr) { | |
String[] xArr = strXArr.split(" "); | |
String[] yArr = strYArr.split(" "); | |
BigInteger res = new BigInteger("0"); | |
int len = xArr.length; | |
int[] iXArr = new int[len]; | |
int[] iYArr = new int[len]; |
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 class StoreCredit { | |
public String buyTwo(int price, int numOfItems, int[] itemPrices) { | |
for(int i=0;i<numOfItems;i++) { | |
for(int j=0;j<numOfItems;j++) { | |
if(i != j) { | |
if(itemPrices[i] + itemPrices[j] == price) { | |
return ((i + 1) + " " + (j + 1)); | |
} | |
} | |
} |