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.util.Arrays; | |
import java.util.List; | |
public class Pascal { | |
public static void main(String[] args) { | |
int numberOfRows = 8; | |
String blank = " "; | |
List<List<Integer>> listOfList = new ArrayList<>(); |
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 algo; | |
public class LinkedListReverse { | |
public static void main(String[] args) throws Exception { | |
Node<Integer> node = new Node(1); | |
node.next = new Node(2); | |
node.next.next = new Node(3); | |
node.next.next.next = new Node(4); | |
node.next.next.next.next = new Node(5); |
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 algo; | |
public class Score { | |
public static void main(String[] args) { | |
String[] nums = { "5", "-2", "4", "Z", "X", "9", "+", "+" }; // 27 | |
// String[] nums = { "1", "2", "4", "Z"}; // 3 | |
System.out.println(findScore(nums, nums.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
package hackoranko | |
object LookAndSay { | |
def LookAndSay(start: String, n: Int): String = { | |
var first = start(0) | |
var tmpStart = new StringBuilder(start(0).toString() + "1") | |
for (t <- start.tail) { |
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 algo | |
class Roman(kings: Array[String]) { | |
val basicLetters = Map( | |
'I' -> 1, | |
'V' -> 5, | |
'X' -> 10, | |
'L' -> 50, | |
'C' -> 100, |
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 oasis; | |
public class Tree { | |
public Student head = null; | |
public void add(Integer number, String name, String surname) { | |
Student student = new Student(number, name, surname); | |
if (head == null) { | |
head = student; | |
} 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 learn; | |
public class MiddleWordSwap { | |
public static void main(String[] args) { | |
char[] str = "Java is nice but Scala is even better :)".toCharArray(); | |
char[] goal = "Java is nice but :) is even better Scala".toCharArray(); | |
System.out.println("Original: '" + new String(str) + "'"); | |
str = rearrange(str); |
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 teach; | |
public class MirrorsEnd { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
String[] words = { "abXYZba", "abca", "aba", "Hi and iH", "123and then 321" }; |
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 teach; | |
public class FindBalance { | |
/** | |
* write a recursion function that will state a given string has balanced | |
* parenthesis. | |
*/ | |
public static void main(String[] args) { | |
String[][] words = { |
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 teach; | |
public class ProjectEulerProblem4 { | |
/** | |
* A palindromic number reads the same both ways. The largest palindrome made | |
* from the product of two 2-digit numbers is 9009 = 91 x 99. | |
* Find the largest palindrome made from the product of two 3-digit numbers. | |
*/ | |
private static final int MAX = 999; |
NewerOlder