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 Solution { | |
public boolean equationsPossible(String[] equations) { | |
HashMap<Character, ArrayList<Character>> equalGraph = new HashMap<>(); | |
for(String equation: equations) | |
{ | |
if(equation.charAt(1)=='=') | |
{ | |
Character var1 = equation.charAt(0); | |
Character var2 = equation.charAt(3); |
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 org.junit.Test; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import static org.junit.Assert.assertTrue; | |
public class Program { |
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 Solution { | |
public int evalRPN(String[] tokens) { | |
Stack<Integer> stack = new Stack<>(); | |
for(String s: tokens) | |
{ | |
if(s.matches("-?\\d+")) | |
{ | |
stack.push(Integer.valueOf(s)); | |
} | |
else |
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
package berke; | |
import java.util.*; | |
public class Main | |
{ | |
private static Boolean found = false; | |
private static Double answer = -1d; | |
// "static void main" must be defined in a public class. |
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 PasswordService | |
{ | |
private PasswordHasher passwordHasher; | |
public PasswordService(PasswordHasher passwordHasher) | |
{ | |
this.passwordHasher = passwordHasher; | |
} | |
void hashPassword(String password) |
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 PasswordService | |
{ | |
private Base64Hasher hasher = new Base64Hasher(); | |
void hashPassword(String password) | |
{ | |
hasher.hashPassword(password); | |
} | |
} |
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 abstract class Hashed | |
{ | |
PasswordHasher passwordHasher; | |
String hash; | |
public void generateHash(String password) | |
{ | |
hash = passwordHasher.hashPassword(password); | |
} | |
} |
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 Base64 extends Hashed | |
{ | |
public Base64() | |
{ | |
this.passwordHasher = new Base64Hasher(); | |
} | |
} |
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 abstract class Hashed | |
{ | |
PasswordHasher passwordHasher; | |
String hash; | |
abstract void generateHash(String password); | |
} |
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 UnHashed implements PasswordHasher | |
{ | |
@Override | |
public String hashPassword(String password) | |
{ | |
return password; | |
} | |
} |
NewerOlder