Skip to content

Instantly share code, notes, and snippets.

View tmosest's full-sized avatar

Tyler Moses tmosest

View GitHub Profile
@tmosest
tmosest / Solutions.java
Created October 13, 2016 01:53
Hackerrank: Utopian Tree
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);
@tmosest
tmosest / Solution.java
Created October 12, 2016 00:52
Hackerrank: Fair Rations
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);
@tmosest
tmosest / Solution.java
Created October 12, 2016 00:42
Hackerrank: Running Time and Complexity
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);
@tmosest
tmosest / Solution.java
Created October 10, 2016 07:37
Hackerrank: Absolute Permutation
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);
@tmosest
tmosest / removeDuplicates.java
Created October 10, 2016 07:34
Hackerrank: Day 30: More Linked List
public static Node removeDuplicates(Node head) {
if (head == null || head.next == null){
return head;
}
if (head.data == head.next.data){
head.next = head.next.next;
removeDuplicates(head);
}else{
removeDuplicates(head.next);
}
@tmosest
tmosest / solution.py
Created October 9, 2016 09:37
Hackerrank: PacMan DFS: Pyton3
class vector:
x=None
y=None
parent=None
dist=0
def __init__(self,x,y):
self.x=x
self.y=y
@tmosest
tmosest / Solution.java
Created October 9, 2016 09:12
Hackerrank: Minimum Distance
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
@tmosest
tmosest / levelOrder.java
Created October 9, 2016 09:03
Hackerrank: Day 23: BST Level-Order Traversal
static void levelOrder(Node root){
Queue<Node> queue = new LinkedList();
queue.add(root);
while(!queue.isEmpty()){
Node current = queue.remove();
System.out.print(current.data+" ");
if (current.left!=null) queue.add(current.left);
if (current.right!=null) queue.add(current.right);
}
@tmosest
tmosest / getHeight.java
Created October 9, 2016 08:46
Hackerrank: Day 22: Binary Search Tress
public static int getHeight(Node root) {
int heightLeft = 0;
int heightRight = 0;
if (root.left != null) {
heightLeft = getHeight(root.left) + 1;
}
if (root.right != null) {
heightRight = getHeight(root.right) + 1;
}
return (heightLeft > heightRight ? heightLeft : heightRight);
@tmosest
tmosest / Solution.java
Created October 9, 2016 08:42
Hackerrank: Day 0: Mean, Median, and Mode
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);