From 7034e7127cd4e99fe15ece0a27e68b7b1b0448bf Mon Sep 17 00:00:00 2001 From: rshaghoulian <9rodney@gmail.com> Date: Sat, 18 Feb 2017 23:43:07 -0600 Subject: [PATCH] Added 26 solutions --- 10 Days of Statistics/README.md | 1 + .../Solution.java | 0 .../Solution.java | 0 .../Solution.java | 0 .../Solution.java | 0 .../Solution.java | 0 .../Solution.java | 0 .../Solution.java | 0 .../Solution.java | 15 +- .../Solution.java | 0 .../Solution.java | 0 30 Days of Code/README.md | 6 + Algorithms/README.md | 21 +-- .../Arrays - Left Rotation/Solution.java | 8 +- .../Stacks - Balanced Brackets/Solution.java | 62 ++++---- .../Solution.java | 20 +-- .../Arrays/2D Array - DS/Solution.java | 39 +++++ .../Arrays/Arrays - DS/Solution.java | 23 +++ .../Arrays/Left Rotation/Solution.java | 53 +++++++ .../Arrays/Sparse Arrays/Solution.java | 36 +++++ .../Find the Running Median/Solution.java | 73 +++++++++ .../Cycle Detection/Solution.java | 31 ++++ .../Linked Lists/Delete a Node/Solution.java | 30 ++++ .../Solution.java | 26 ++++ .../Solution.java | 30 ++++ .../Solution.java | 36 +++++ .../Solution.java | 22 +++ .../Print in Reverse/Solution.java | 22 +++ .../Solution.java | 24 +++ .../Queue using Two Stacks/Solution.java | 69 +++++++++ Data Structures/README.md | 111 +++++++++++++ .../Stacks/Balanced Brackets/Solution.java | 45 ++++++ .../Solution.java | 26 ++++ Data Structures/Trie/Contacts/Solution.java | 65 ++++++++ .../Data Structures/Java BitSet/Solution.java | 62 ++++++++ .../Java Comparator/Solution.java | 47 ++++++ .../Java Dequeue/Solution.java | 55 +++++++ .../Java Generics/Solution.java | 35 +++++ .../Java Hashset/Solution.java | 31 ++++ Java/Data Structures/Java List/Solution.java | 39 +++++ Java/Data Structures/Java Map/Solution.java | 35 +++++ Java/Data Structures/Java Sort/Solution.java | 68 ++++++++ Java/Data Structures/Java Stack/Solution.java | 44 ++++++ Java/README.md | 91 ++++++++--- README.md | 146 ++++++++++++++++++ 45 files changed, 1458 insertions(+), 89 deletions(-) rename 30 Days of Code/{Day 0 - Hello, World => Day 00 - Hello, World}/Solution.java (100%) rename 30 Days of Code/{Day 1 - Data Types => Day 01 - Data Types}/Solution.java (100%) rename 30 Days of Code/{Day 2 - Operators => Day 02 - Operators}/Solution.java (100%) rename 30 Days of Code/{Day 3 - Intro to Conditional Statements => Day 03 - Intro to Conditional Statements}/Solution.java (100%) rename 30 Days of Code/{Day 4 - Class vs. Instance => Day 04 - Class vs. Instance}/Solution.java (100%) rename 30 Days of Code/{Day 5 - Loops => Day 05 - Loops}/Solution.java (100%) rename 30 Days of Code/{Day 6 - Let's Review => Day 06 - Let's Review}/Solution.java (100%) rename 30 Days of Code/{Day 7 - Arrays => Day 07 - Arrays}/Solution.java (58%) rename 30 Days of Code/{Day 8 - Dictionaries and Maps => Day 08 - Dictionaries and Maps}/Solution.java (100%) rename 30 Days of Code/{Day 9 - Recursion => Day 09 - Recursion}/Solution.java (100%) create mode 100644 Data Structures/Arrays/2D Array - DS/Solution.java create mode 100644 Data Structures/Arrays/Arrays - DS/Solution.java create mode 100644 Data Structures/Arrays/Left Rotation/Solution.java create mode 100644 Data Structures/Arrays/Sparse Arrays/Solution.java create mode 100644 Data Structures/Heap/Find the Running Median/Solution.java create mode 100644 Data Structures/Linked Lists/Cycle Detection/Solution.java create mode 100644 Data Structures/Linked Lists/Delete a Node/Solution.java create mode 100644 Data Structures/Linked Lists/Delete duplicate-value nodes from a sorted linked list/Solution.java create mode 100644 Data Structures/Linked Lists/Insert a Node at the Tail of a Linked List/Solution.java create mode 100644 Data Structures/Linked Lists/Insert a node at a specific position in a linked list/Solution.java create mode 100644 Data Structures/Linked Lists/Insert a node at the head of a linked list/Solution.java create mode 100644 Data Structures/Linked Lists/Print in Reverse/Solution.java create mode 100644 Data Structures/Linked Lists/Print the Elements of a Linked List/Solution.java create mode 100644 Data Structures/Queues/Queue using Two Stacks/Solution.java create mode 100644 Data Structures/README.md create mode 100644 Data Structures/Stacks/Balanced Brackets/Solution.java create mode 100644 Data Structures/Trees/Is This a Binary Search Tree/Solution.java create mode 100644 Data Structures/Trie/Contacts/Solution.java create mode 100644 Java/Data Structures/Java BitSet/Solution.java create mode 100644 Java/Data Structures/Java Comparator/Solution.java create mode 100644 Java/Data Structures/Java Dequeue/Solution.java create mode 100644 Java/Data Structures/Java Generics/Solution.java create mode 100644 Java/Data Structures/Java Hashset/Solution.java create mode 100644 Java/Data Structures/Java List/Solution.java create mode 100644 Java/Data Structures/Java Map/Solution.java create mode 100644 Java/Data Structures/Java Sort/Solution.java create mode 100644 Java/Data Structures/Java Stack/Solution.java diff --git a/10 Days of Statistics/README.md b/10 Days of Statistics/README.md index 8388d73..e44cfc8 100644 --- a/10 Days of Statistics/README.md +++ b/10 Days of Statistics/README.md @@ -28,3 +28,4 @@ | Tutorials | 10 Days of Statistics | 7 | [Spearman's Rank Correlation Coefficient](https://www.hackerrank.com/challenges/s10-spearman-rank-correlation-coefficient) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/10%20Days%20of%20Statistics/Day%207%20-%20Spearman%27s%20Rank%20Correlation%20Coefficient/Solution.java) | | Tutorials | 10 Days of Statistics | 8 | [Least Square Regression Line](https://www.hackerrank.com/challenges/s10-least-square-regression-line) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/10%20Days%20of%20Statistics/Day%208%20-%20Least%20Square%20Regression%20Rate/Solution.java) | | Tutorials | 10 Days of Statistics | 8 | [Pearson Correlation Coefficient II](https://www.hackerrank.com/challenges/s10-mcq-7) | Multiple Choice | [Solution.txt](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/10%20Days%20of%20Statistics/Day%208%20-%20Pearson%20Correlation%20Coefficient%20II/Solution.txt) | +| Tutorials | 10 Days of Statistics | 9 | [Multiple Linear Regression](https://www.hackerrank.com/challenges/s10-multiple-linear-regression) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/10%20Days%20of%20Statistics/Day%209%20-%20Multiple%20Linear%20Regression/Solution.java) | diff --git a/30 Days of Code/Day 0 - Hello, World/Solution.java b/30 Days of Code/Day 00 - Hello, World/Solution.java similarity index 100% rename from 30 Days of Code/Day 0 - Hello, World/Solution.java rename to 30 Days of Code/Day 00 - Hello, World/Solution.java diff --git a/30 Days of Code/Day 1 - Data Types/Solution.java b/30 Days of Code/Day 01 - Data Types/Solution.java similarity index 100% rename from 30 Days of Code/Day 1 - Data Types/Solution.java rename to 30 Days of Code/Day 01 - Data Types/Solution.java diff --git a/30 Days of Code/Day 2 - Operators/Solution.java b/30 Days of Code/Day 02 - Operators/Solution.java similarity index 100% rename from 30 Days of Code/Day 2 - Operators/Solution.java rename to 30 Days of Code/Day 02 - Operators/Solution.java diff --git a/30 Days of Code/Day 3 - Intro to Conditional Statements/Solution.java b/30 Days of Code/Day 03 - Intro to Conditional Statements/Solution.java similarity index 100% rename from 30 Days of Code/Day 3 - Intro to Conditional Statements/Solution.java rename to 30 Days of Code/Day 03 - Intro to Conditional Statements/Solution.java diff --git a/30 Days of Code/Day 4 - Class vs. Instance/Solution.java b/30 Days of Code/Day 04 - Class vs. Instance/Solution.java similarity index 100% rename from 30 Days of Code/Day 4 - Class vs. Instance/Solution.java rename to 30 Days of Code/Day 04 - Class vs. Instance/Solution.java diff --git a/30 Days of Code/Day 5 - Loops/Solution.java b/30 Days of Code/Day 05 - Loops/Solution.java similarity index 100% rename from 30 Days of Code/Day 5 - Loops/Solution.java rename to 30 Days of Code/Day 05 - Loops/Solution.java diff --git a/30 Days of Code/Day 6 - Let's Review/Solution.java b/30 Days of Code/Day 06 - Let's Review/Solution.java similarity index 100% rename from 30 Days of Code/Day 6 - Let's Review/Solution.java rename to 30 Days of Code/Day 06 - Let's Review/Solution.java diff --git a/30 Days of Code/Day 7 - Arrays/Solution.java b/30 Days of Code/Day 07 - Arrays/Solution.java similarity index 58% rename from 30 Days of Code/Day 7 - Arrays/Solution.java rename to 30 Days of Code/Day 07 - Arrays/Solution.java index eaf8396..117d9ec 100644 --- a/30 Days of Code/Day 7 - Arrays/Solution.java +++ b/30 Days of Code/Day 07 - Arrays/Solution.java @@ -5,20 +5,19 @@ import java.util.Scanner; public class Solution { - public static void main(String[] args) { /* Read and save input */ - Scanner in = new Scanner(System.in); - int size = in.nextInt(); - int [] arr = new int[size]; - for(int i = 0; i < size; i++) { - arr[i] = in.nextInt(); + Scanner scan = new Scanner(System.in); + int size = scan.nextInt(); + int [] array = new int[size]; + for (int i = 0; i < size; i++) { + array[i] = scan.nextInt(); } - in.close(); + scan.close(); /* Print elements in reverse order */ for (int i = size - 1; i >= 0; i--) { - System.out.print(arr[i] + " "); + System.out.print(array[i] + " "); } } } diff --git a/30 Days of Code/Day 8 - Dictionaries and Maps/Solution.java b/30 Days of Code/Day 08 - Dictionaries and Maps/Solution.java similarity index 100% rename from 30 Days of Code/Day 8 - Dictionaries and Maps/Solution.java rename to 30 Days of Code/Day 08 - Dictionaries and Maps/Solution.java diff --git a/30 Days of Code/Day 9 - Recursion/Solution.java b/30 Days of Code/Day 09 - Recursion/Solution.java similarity index 100% rename from 30 Days of Code/Day 9 - Recursion/Solution.java rename to 30 Days of Code/Day 09 - Recursion/Solution.java diff --git a/30 Days of Code/README.md b/30 Days of Code/README.md index 00bf25e..0be803d 100644 --- a/30 Days of Code/README.md +++ b/30 Days of Code/README.md @@ -12,3 +12,9 @@ | Tutorials | 30 Days of Code | 7 | [Arrays](https://www.hackerrank.com/challenges/30-arrays) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%207%20-%20Arrays/Solution.java) | | Tutorials | 30 Days of Code | 8 | [Dictionaries and Maps](https://www.hackerrank.com/challenges/30-dictionaries-and-maps) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%208%20-%20Dictionaries%20and%20Maps/Solution.java) | | Tutorials | 30 Days of Code | 9 | [Recursion](https://www.hackerrank.com/challenges/30-recursion) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%209%20-%20Recursion/Solution.java) | +| Tutorials | 30 Days of Code | 10 | [Binary Numbers](https://www.hackerrank.com/challenges/30-binary-numbers) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%2010%20-%20Binary%20Numbers/Solution.java) | +| Tutorials | 30 Days of Code | 11 | [2D Arrays](https://www.hackerrank.com/challenges/30-2d-arrays) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%2011%20-%202D%20Arrays/Solution.java) | +| Tutorials | 30 Days of Code | 12 | [Inheritance](https://www.hackerrank.com/challenges/30-inheritance) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%2012%20-%20Inheritance/Solution.java) | +| Tutorials | 30 Days of Code | 13 | [Abstract Classes](https://www.hackerrank.com/challenges/30-abstract-classes) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%2013%20-%20Abstract%20Classes/Solution.java) | +| Tutorials | 30 Days of Code | 14 | [Scope](https://www.hackerrank.com/challenges/30-scope) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%2014%20-%20Scope/Solution.java) | +| Tutorials | 30 Days of Code | 15 | [Linked List](https://www.hackerrank.com/challenges/30-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/30%20Days%20of%20Code/Day%2015%20-%20Linked%20List/Solution.java) | diff --git a/Algorithms/README.md b/Algorithms/README.md index 4451615..9f61c8b 100644 --- a/Algorithms/README.md +++ b/Algorithms/README.md @@ -1,11 +1,14 @@ ## Algorithms -| Domain | Subdomain | Challenge | Difficulty | Solution | -|:----------:|:---------:|:----------------------------------------------------------------------------------:|:----------:|:------------------------------------------------------------------------------------------------------------------------------------------:| -| Algorithms | Warmup | [Solve Me First](https://www.hackerrank.com/challenges/solve-me-first) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Solve%20Me%20First/Solution.java) | -| Algorithms | Warmup | [Simple Array Sum](https://www.hackerrank.com/challenges/simple-array-sum) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Simple%20Array%20Sum/Solution.java) | -| Algorithms | Warmup | [Compare the Triplets](https://www.hackerrank.com/challenges/compare-the-triplets) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Compare%20the%20Triplets/Solution.java) | -| Algorithms | Warmup | [A Very Big Sum](https://www.hackerrank.com/challenges/a-very-big-sum) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/A%20Very%20Big%20Sum/Solution.java) | -| Algorithms | Warmup | [Diagonal Difference](https://www.hackerrank.com/challenges/diagonal-difference) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Diagonal%20Difference/Solution.java) | -| Algorithms | Warmup | [Plus Minus](https://www.hackerrank.com/challenges/plus-minus) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Plus%20Minus/Solution.java) | -| Algorithms | Warmup | [Staircase](https://www.hackerrank.com/challenges/staircase) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Staircase/Solution.java) | +| Domain | Subdomain | Challenge | Difficulty | Solution | +|:----------:|:--------------:|:----------------------------------------------------------------------------------------:|:----------:|:---------------------------------------------------------------------------------------------------------------------------------------------:| +| Algorithms | Warmup | [Solve Me First](https://www.hackerrank.com/challenges/solve-me-first) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Solve%20Me%20First/Solution.java) | +| Algorithms | Warmup | [Simple Array Sum](https://www.hackerrank.com/challenges/simple-array-sum) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Simple%20Array%20Sum/Solution.java) | +| Algorithms | Warmup | [Compare the Triplets](https://www.hackerrank.com/challenges/compare-the-triplets) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Compare%20the%20Triplets/Solution.java) | +| Algorithms | Warmup | [A Very Big Sum](https://www.hackerrank.com/challenges/a-very-big-sum) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/A%20Very%20Big%20Sum/Solution.java) | +| Algorithms | Warmup | [Diagonal Difference](https://www.hackerrank.com/challenges/diagonal-difference) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Diagonal%20Difference/Solution.java) | +| Algorithms | Warmup | [Plus Minus](https://www.hackerrank.com/challenges/plus-minus) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Plus%20Minus/Solution.java) | +| Algorithms | Warmup | [Staircase](https://www.hackerrank.com/challenges/staircase) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Staircase/Solution.java) | +| Algorithms | Warmup | [Time Conversion](https://www.hackerrank.com/challenges/time-conversion) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Time%20Conversion/Solution.java) | +| Algorithms | Warmup | [Circular Array Rotation](https://www.hackerrank.com/challenges/circular-array-rotation) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Circular%20Array%20Rotation/Solution.java) | +| Algorithms | Implementation | [Mini-max Sum](https://www.hackerrank.com/challenges/mini-max-sum) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Implementation/Mini-Max%20Sum/Solution.java) | diff --git a/Cracking the Coding Interview/Data Structures/Arrays - Left Rotation/Solution.java b/Cracking the Coding Interview/Data Structures/Arrays - Left Rotation/Solution.java index 15f5725..046ba6c 100644 --- a/Cracking the Coding Interview/Data Structures/Arrays - Left Rotation/Solution.java +++ b/Cracking the Coding Interview/Data Structures/Arrays - Left Rotation/Solution.java @@ -4,9 +4,8 @@ import java.util.Scanner; -/* Runtime: O(n) - Space Complexity: O(1) by doing an "in place" rotation -*/ +// Runtime: O(n) +// Space Complexity: O(1) by doing an "in place" rotation public class Solution { public static void main(String[] args) { @@ -15,7 +14,7 @@ public class Solution { int size = scan.nextInt(); int numRotations = scan.nextInt(); int array[] = new int[size]; - for(int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) { array[i] = scan.nextInt(); } scan.close(); @@ -52,4 +51,3 @@ public class Solution { array[j] = temp; } } - diff --git a/Cracking the Coding Interview/Data Structures/Stacks - Balanced Brackets/Solution.java b/Cracking the Coding Interview/Data Structures/Stacks - Balanced Brackets/Solution.java index 718970d..05e7785 100644 --- a/Cracking the Coding Interview/Data Structures/Stacks - Balanced Brackets/Solution.java +++ b/Cracking the Coding Interview/Data Structures/Stacks - Balanced Brackets/Solution.java @@ -4,48 +4,42 @@ import java.util.Scanner; import java.util.Stack; +import java.util.HashMap; public class Solution { - public static boolean isBalanced(String expression) { + public static void main(String[] args) { + /* Create HashMap to match opening brackets with closing brackets */ + HashMap map = new HashMap<>(); + map.put('(', ')'); + map.put('[', ']'); + map.put('{', '}'); + + /* Test each expression for validity */ + Scanner scan = new Scanner(System.in); + int t = scan.nextInt(); + while (t-- > 0) { + String expression = scan.next(); + System.out.println(isBalanced(expression, map) ? "YES" : "NO" ); + } + scan.close(); + } + + public static boolean isBalanced(String expression, HashMap map) { + /* Odd length strings are not balanced */ + if ((expression.length() % 2) != 0) { + return false; + } + Stack stack = new Stack<>(); for (int i = 0; i < expression.length(); i++) { Character ch = expression.charAt(i); - switch (ch) { - case '(': - case '[': - case '{': - stack.push(ch); - break; - case ')': - if (stack.isEmpty() || stack.pop() != '(') { // makes sure not to call .pop() on an empty stack - return false; - } - break; - case ']': - if (stack.isEmpty() || stack.pop() != '[') { - return false; - } - break; - case '}': - if (stack.isEmpty() || stack.pop() != '{') { - return false; - } - break; - default: - break; + if (map.containsKey(ch)) { + stack.push(ch); + } else if (stack.isEmpty() || ch != map.get(stack.pop())) { + return false; } } return stack.isEmpty(); } - - public static void main(String[] args) { - Scanner scan = new Scanner(System.in); - int t = scan.nextInt(); - for (int a0 = 0; a0 < t; a0++) { - String expression = scan.next(); - System.out.println( (isBalanced(expression)) ? "YES" : "NO" ); - } - scan.close(); - } } diff --git a/Cracking the Coding Interview/Data Structures/Trees - Is This a Binary Search Tree/Solution.java b/Cracking the Coding Interview/Data Structures/Trees - Is This a Binary Search Tree/Solution.java index 2b4e188..e740f4d 100644 --- a/Cracking the Coding Interview/Data Structures/Trees - Is This a Binary Search Tree/Solution.java +++ b/Cracking the Coding Interview/Data Structures/Trees - Is This a Binary Search Tree/Solution.java @@ -11,14 +11,16 @@ The Node class is defined as follows: Node right; } */ - boolean checkBST(Node root) { - return checkBST(root, 0, 10000); // the problem stated this is the range of values. - } + +boolean checkBST(Node root) { + return checkBST(root, 0, 10000); // range of values in problem +} - boolean checkBST(Node node, int min, int max) { - if (node == null) - return true; - if (node.data < min || node.data > max) - return false; - return checkBST(node.left, min, node.data - 1) && checkBST(node.right, node.data + 1, max); +boolean checkBST(Node node, int min, int max) { + if (node == null) { + return true; + } else if (node.data < min || node.data > max) { + return false; } + return checkBST(node.left, min, node.data - 1) && checkBST(node.right, node.data + 1, max); +} diff --git a/Data Structures/Arrays/2D Array - DS/Solution.java b/Data Structures/Arrays/2D Array - DS/Solution.java new file mode 100644 index 0000000..645294a --- /dev/null +++ b/Data Structures/Arrays/2D Array - DS/Solution.java @@ -0,0 +1,39 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; + +public class Solution { + + public static void main(String [] args) { + Scanner scan = new Scanner(System.in); + int arr[][] = new int[6][6]; + for (int row = 0; row < 6; row++) { + for (int col = 0; col < 6; col++) { + arr[row][col] = scan.nextInt(); + } + } + scan.close(); + + System.out.println(maxHourglass(arr)); + } + + public static int maxHourglass(int [][] arr) { + int max = Integer.MIN_VALUE; + for (int row = 0; row < 4; row++) { + for (int col = 0; col < 4; col++) { + int sum = findSum(arr, row, col); + max = Math.max(max, sum); + } + } + return max; + } + + private static int findSum(int [][] arr, int r, int c) { + int sum = arr[r+0][c+0] + arr[r+0][c+1] + arr[r+0][c+2] + + arr[r+1][c+1] + + arr[r+2][c+0] + arr[r+2][c+1] + arr[r+2][c+2]; + return sum; + } +} diff --git a/Data Structures/Arrays/Arrays - DS/Solution.java b/Data Structures/Arrays/Arrays - DS/Solution.java new file mode 100644 index 0000000..117d9ec --- /dev/null +++ b/Data Structures/Arrays/Arrays - DS/Solution.java @@ -0,0 +1,23 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; + +public class Solution { + public static void main(String[] args) { + /* Read and save input */ + Scanner scan = new Scanner(System.in); + int size = scan.nextInt(); + int [] array = new int[size]; + for (int i = 0; i < size; i++) { + array[i] = scan.nextInt(); + } + scan.close(); + + /* Print elements in reverse order */ + for (int i = size - 1; i >= 0; i--) { + System.out.print(array[i] + " "); + } + } +} diff --git a/Data Structures/Arrays/Left Rotation/Solution.java b/Data Structures/Arrays/Left Rotation/Solution.java new file mode 100644 index 0000000..046ba6c --- /dev/null +++ b/Data Structures/Arrays/Left Rotation/Solution.java @@ -0,0 +1,53 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; + +// Runtime: O(n) +// Space Complexity: O(1) by doing an "in place" rotation +public class Solution { + + public static void main(String[] args) { + /* Read and save input */ + Scanner scan = new Scanner(System.in); + int size = scan.nextInt(); + int numRotations = scan.nextInt(); + int array[] = new int[size]; + for (int i = 0; i < size; i++) { + array[i] = scan.nextInt(); + } + scan.close(); + + /* Rotate array (in place) using 3 reverse operations */ + numRotations %= size; // to account for numRotations > size + int rotationSpot = size - 1 - numRotations; + reverse(array, 0, size - 1); + reverse(array, 0, rotationSpot); + reverse(array, rotationSpot + 1, size - 1); + + /* Print rotated array */ + for (int i = 0; i < size; i++) { + System.out.print(array[i] + " "); + } + } + + /* Reverses array from "start" to "end" inclusive */ + private static void reverse(int [] array, int start, int end) { + if (array == null || start < 0 || start >= array.length || + end < 0 || end >= array.length || start >= end) { + return; + } + int mid = (start + end) / 2; + for (int i = start; i <= mid; i++) { + int offset = i - start; + swap(array, start + offset, end - offset); + } + } + + private static void swap(int [] array, int i, int j) { + int temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } +} diff --git a/Data Structures/Arrays/Sparse Arrays/Solution.java b/Data Structures/Arrays/Sparse Arrays/Solution.java new file mode 100644 index 0000000..3243e96 --- /dev/null +++ b/Data Structures/Arrays/Sparse Arrays/Solution.java @@ -0,0 +1,36 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.HashMap; + +public class Solution { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int N = scan.nextInt(); + scan.nextLine(); // gets rid of pesky newline + HashMap map = new HashMap<>(); + + for (int i = 0; i < N; i++) { + String str = scan.nextLine(); + if (map.containsKey(str)) { + map.put(str, map.get(str) + 1); + } else { + map.put(str, 1); + } + } + + int Q = scan.nextInt(); + scan.nextLine(); // gets rid of pesky newline + + for (int i = 0; i < Q; i++) { + String str = scan.nextLine(); + if (map.containsKey(str)) { + System.out.println(map.get(str)); + } else { + System.out.println(0); + } + } + } +} diff --git a/Data Structures/Heap/Find the Running Median/Solution.java b/Data Structures/Heap/Find the Running Median/Solution.java new file mode 100644 index 0000000..9499126 --- /dev/null +++ b/Data Structures/Heap/Find the Running Median/Solution.java @@ -0,0 +1,73 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.PriorityQueue; +import java.util.Collections; + +/* + We want either + 1) maxHeap.size() == minHeap.size() + 2) maxHeap.size() - 1 = minHeap.size() + to always be true + */ +public class Solution { + + private static PriorityQueue minHeap = new PriorityQueue<>(); // keeps track of the LARGE numbers + private static PriorityQueue maxHeap = new PriorityQueue<>(Collections.reverseOrder()); // keeps track of the SMALL numbers + + public static void main(String[] args) { + /* Read input */ + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + int[] a = new int[n]; + for (int a_i=0; a_i < n; a_i++) { + a[a_i] = scan.nextInt(); + } + scan.close(); + + medianTracker(a); + } + + public static void medianTracker(int [] array) { + for (int i = 0; i < array.length; i++) { + addNumber(array[i]); + System.out.println(getMedian()); + } + } + + private static void addNumber(int num) { + if (maxHeap.isEmpty()) { + maxHeap.add(num); + } + else if (maxHeap.size() == minHeap.size()) { + if (num > maxHeap.peek()) { + minHeap.add(num); + maxHeap.add(minHeap.remove()); + } + else { + maxHeap.add(num); + } + } + else if (maxHeap.size() > minHeap.size()) { + if (num > maxHeap.peek()) { + minHeap.add(num); + } + else { + maxHeap.add(num); + minHeap.add(maxHeap.remove()); + } + } + // Note: maxHeap will never be smaller size than minHeap + } + + private static double getMedian() { // problem statement said: will always have at least 1 element + if (maxHeap.size() > minHeap.size()) { + return maxHeap.peek(); + } + else { // same size + return (maxHeap.peek() + minHeap.peek()) / 2.0; + } + } +} diff --git a/Data Structures/Linked Lists/Cycle Detection/Solution.java b/Data Structures/Linked Lists/Cycle Detection/Solution.java new file mode 100644 index 0000000..7c255de --- /dev/null +++ b/Data Structures/Linked Lists/Cycle Detection/Solution.java @@ -0,0 +1,31 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* +Detect a cycle in a linked list. Note that the head pointer may be 'null' if the list is empty. + +A Node is defined as: + class Node { + int data; + Node next; + } +*/ + +/* If "slow" and "fast" collide, we must have a cycle */ +boolean hasCycle(Node head) { + if (head == null) + return false; + + Node slow = head; // moves 1 Node at a time + Node fast = head; // moves 2 Nodes at a time + + while (fast != null && fast.next != null) { + slow = slow.next; + fast = fast.next.next; + if (slow == fast) { + return true; // since "slow" and "fast" collided + } + } + return false; +} diff --git a/Data Structures/Linked Lists/Delete a Node/Solution.java b/Data Structures/Linked Lists/Delete a Node/Solution.java new file mode 100644 index 0000000..d187643 --- /dev/null +++ b/Data Structures/Linked Lists/Delete a Node/Solution.java @@ -0,0 +1,30 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* + Delete Node at a given position in a linked list + head pointer input could be NULL as well for empty list + Node is defined as + class Node { + int data; + Node next; + } +*/ + // This is a "method-only" submission. + // You only need to complete this method. + +Node Delete(Node head, int position) { + if (head == null) { + return null; + } else if (position == 0) { + return head.next; + } else { + Node n = head; + for (int i = 0; i < position - 1; i++) { + n = n.next; + } + n.next = n.next.next; + return head; + } +} diff --git a/Data Structures/Linked Lists/Delete duplicate-value nodes from a sorted linked list/Solution.java b/Data Structures/Linked Lists/Delete duplicate-value nodes from a sorted linked list/Solution.java new file mode 100644 index 0000000..28e5b93 --- /dev/null +++ b/Data Structures/Linked Lists/Delete duplicate-value nodes from a sorted linked list/Solution.java @@ -0,0 +1,26 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* +Node is defined as + class Node { + int data; + Node next; + } +*/ + +Node RemoveDuplicates(Node head) { + if (head == null) { + return null; + } + Node n = head; + while (n.next != null) { + if (n.data == n.next.data) { + n.next = n.next.next; + } else { + n = n.next; + } + } + return head; +} diff --git a/Data Structures/Linked Lists/Insert a Node at the Tail of a Linked List/Solution.java b/Data Structures/Linked Lists/Insert a Node at the Tail of a Linked List/Solution.java new file mode 100644 index 0000000..739136c --- /dev/null +++ b/Data Structures/Linked Lists/Insert a Node at the Tail of a Linked List/Solution.java @@ -0,0 +1,30 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* + Insert Node at the end of a linked list + head pointer input could be NULL as well for empty list + Node is defined as + class Node { + int data; + Node next; + } +*/ + +Node Insert(Node head, int data) { + Node n = new Node(); + n.data = data; + n.next = null; + + if (head == null) { + return n; + } else { + Node curr = head; + while (curr.next != null) { + curr = curr.next; + } + curr.next = n; + return head; + } +} diff --git a/Data Structures/Linked Lists/Insert a node at a specific position in a linked list/Solution.java b/Data Structures/Linked Lists/Insert a node at a specific position in a linked list/Solution.java new file mode 100644 index 0000000..c30ba60 --- /dev/null +++ b/Data Structures/Linked Lists/Insert a node at a specific position in a linked list/Solution.java @@ -0,0 +1,36 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* + Insert Node at a given position in a linked list + head can be NULL + First element in the linked list is at position 0 + Node is defined as + class Node { + int data; + Node next; + } +*/ + +Node InsertNth(Node head, int data, int position) { + Node newNode = new Node(); + newNode.data = data; + + if (position == 0) { + newNode.next = head; + return newNode; + } else { + /* Get Node one element before desired position */ + Node curr = head; + for (int i = 0; i < position - 1; i++) { + curr = curr.next; + } + + /* Insert our new Node */ + newNode.next = curr.next; + curr.next = newNode; + + return head; + } +} diff --git a/Data Structures/Linked Lists/Insert a node at the head of a linked list/Solution.java b/Data Structures/Linked Lists/Insert a node at the head of a linked list/Solution.java new file mode 100644 index 0000000..b80073b --- /dev/null +++ b/Data Structures/Linked Lists/Insert a node at the head of a linked list/Solution.java @@ -0,0 +1,22 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* + Insert Node at the beginning of a linked list + head pointer input could be NULL as well for empty list + Node is defined as + class Node { + int data; + Node next; + } +*/ +// This is a "method-only" submission. +// You only need to complete this method. + +Node Insert(Node head, int x) { + Node n = new Node(); + n.data = x; + n.next = head; + return n; +} diff --git a/Data Structures/Linked Lists/Print in Reverse/Solution.java b/Data Structures/Linked Lists/Print in Reverse/Solution.java new file mode 100644 index 0000000..ce39884 --- /dev/null +++ b/Data Structures/Linked Lists/Print in Reverse/Solution.java @@ -0,0 +1,22 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* + Insert Node at the end of a linked list + head pointer input could be NULL as well for empty list + Node is defined as + class Node { + int data; + Node next; + } +*/ + // This is a "method-only" submission. + // You only need to complete this method. + +void ReversePrint(Node head) { + if (head != null) { + ReversePrint(head.next); + System.out.println(head.data); + } +} diff --git a/Data Structures/Linked Lists/Print the Elements of a Linked List/Solution.java b/Data Structures/Linked Lists/Print the Elements of a Linked List/Solution.java new file mode 100644 index 0000000..ef01264 --- /dev/null +++ b/Data Structures/Linked Lists/Print the Elements of a Linked List/Solution.java @@ -0,0 +1,24 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* + Print elements of a linked list on console + head pointer input could be NULL as well for empty list + Node is defined as + class Node { + int data; + Node next; + } +*/ + +// This is a "method-only" submission. +// You only need to complete this method. + +void Print(Node head) { + Node n = head; + while (n != null) { + System.out.println(n.data); + n = n.next; + } +} diff --git a/Data Structures/Queues/Queue using Two Stacks/Solution.java b/Data Structures/Queues/Queue using Two Stacks/Solution.java new file mode 100644 index 0000000..198b8e0 --- /dev/null +++ b/Data Structures/Queues/Queue using Two Stacks/Solution.java @@ -0,0 +1,69 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.Stack; + +public class Solution { + public static void main(String[] args) { + MyQueue queue = new MyQueue(); + + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + + for (int i = 0; i < n; i++) { + int operation = scan.nextInt(); + if (operation == 1) { // enqueue + queue.enqueue(scan.nextInt()); + } else if (operation == 2) { // dequeue + queue.dequeue(); + } else if (operation == 3) { // print/peek + System.out.println(queue.peek()); + } + } + scan.close(); + } + + public static class MyQueue { + private Stack stack1 = new Stack<>(); + private Stack stack2 = new Stack<>(); + + public void enqueue(Integer num) { + stack1.push(num); + } + + public Integer dequeue() { + if (size() == 0) { + return null; + } + if (stack2.isEmpty()) { + shiftStacks(); + } + return stack2.pop(); + } + + public Integer peek() { + if (size() == 0) { + return null; + } + if (stack2.isEmpty()) { + shiftStacks(); + } + return stack2.peek(); + } + + /* Only shifts stacks if necessary */ + private void shiftStacks() { + if (stack2.isEmpty()) { // shifting items while stack2 contains items would mess up our queue's ordering + while ( ! stack1.isEmpty()) { + stack2.push(stack1.pop()); + } + } + } + + public int size() { + return stack1.size() + stack2.size(); + } + } +} diff --git a/Data Structures/README.md b/Data Structures/README.md new file mode 100644 index 0000000..2716966 --- /dev/null +++ b/Data Structures/README.md @@ -0,0 +1,111 @@ +## Data Structures + +| Domain | Subdomain | Challenge | Difficulty | Solution | +|:---------------:|:---------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| Data Structures | Arrays | [Arrays - DS](https://www.hackerrank.com/challenges/arrays-ds) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/Arrays%20-%20DS/Solution.java) | +| Data Structures | Arrays | [2D Array - DS](https://www.hackerrank.com/challenges/2d-array) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/2D%20Array%20-%20DS/Solution.java) | +| Data Structures | Arrays | [Dynamic Array](https://www.hackerrank.com/challenges/dynamic-array) | Easy | Coming Soon! | +| Data Structures | Arrays | [Left Rotation](https://www.hackerrank.com/challenges/array-left-rotation) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/Left%20Rotation/Solution.java) | +| Data Structures | Arrays | [Sparse Arrays](https://www.hackerrank.com/challenges/sparse-arrays) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/Sparse%20Arrays/Solution.java) | +| Data Structures | Arrays | [Algorithmic Crush](https://www.hackerrank.com/challenges/crush) | Hard | Coming Soon! | +| Data Structures | Linked List | [Print the Elements of a Linked List](https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Print%20the%20Elements%20of%20a%20Linked%20List/Solution.java) | +| Data Structures | Linked List | [Insert a Node at the Tail of a Linked List](https://www.hackerrank.com/challenges/insert-a-node-at-the-tail-of-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Insert%20a%20Node%20at%20the%20Tail%20of%20a%20Linked%20List/Solution.java) | +| Data Structures | Linked List | [Insert a node at the head of a linked list](https://www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Insert%20a%20node%20at%20the%20head%20of%20a%20linked%20list/Solution.java) | +| Data Structures | Linked List | [Insert a node at a specific position in a linked list](https://www.hackerrank.com/challenges/insert-a-node-at-a-specific-position-in-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Insert%20a%20node%20at%20a%20specific%20position%20in%20a%20linked%20list/Solution.java) | +| Data Structures | Linked List | [Delete a Node](https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Delete%20a%20Node/Solution.java) | +| Data Structures | Linked List | [Print in Reverse](https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list-in-reverse) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Print%20in%20Reverse/Solution.java) | +| Data Structures | Linked List | [Reverse a linked list](https://www.hackerrank.com/challenges/reverse-a-linked-list) | Easy | Coming Soon! | +| Data Structures | Linked List | [Compare two linked lists](https://www.hackerrank.com/challenges/compare-two-linked-lists) | Easy | Coming Soon! | +| Data Structures | Linked List | [Merge two sorted linked lists](https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists) | Easy | Coming Soon! | +| Data Structures | Linked List | [Get Node Value](https://www.hackerrank.com/challenges/get-the-value-of-the-node-at-a-specific-position-from-the-tail) | Easy | Coming Soon! | +| Data Structures | Linked List | [Delete duplicate-value nodes from a sorted linked list](https://www.hackerrank.com/challenges/delete-duplicate-value-nodes-from-a-sorted-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Delete%20duplicate-value%20nodes%20from%20a%20sorted%20linked%20list/Solution.java) | +| Data Structures | Linked List | [Cycle Detection](https://www.hackerrank.com/challenges/detect-whether-a-linked-list-contains-a-cycle) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Cycle%20Detection/Solution.java) | +| Data Structures | Linked List | [Find Merge Point of Two Lists](https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists) | Easy | Coming Soon! | +| Data Structures | Linked List | [Inserting a Node Into a Sorted Doubly Linked List](https://www.hackerrank.com/challenges/insert-a-node-into-a-sorted-doubly-linked-list) | Easy | Coming Soon! | +| Data Structures | Linked List | [Reverse a doubly linked list](https://www.hackerrank.com/challenges/reverse-a-doubly-linked-list) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Preorder Traversal](https://www.hackerrank.com/challenges/tree-preorder-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Postorder Traversal](https://www.hackerrank.com/challenges/tree-postorder-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Inorder Traversal](https://www.hackerrank.com/challenges/tree-inorder-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Height of a Binary Tree](https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Top View](https://www.hackerrank.com/challenges/tree-top-view) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Level Order Traversal](https://www.hackerrank.com/challenges/tree-level-order-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Binary Search Tree: Insertion](https://www.hackerrank.com/challenges/binary-search-tree-insertion) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Huffman Decoding](https://www.hackerrank.com/challenges/tree-huffman-decoding) | Medium | Coming Soon! | +| Data Structures | Trees | [Binary Search Tree: Lowest Common Ancestor](https://www.hackerrank.com/challenges/binary-search-tree-lowest-common-ancestor) | Easy | Coming Soon! | +| Data Structures | Trees | [Swap Nodes [Algo]](https://www.hackerrank.com/challenges/swap-nodes-algo) | Medium | Coming Soon! | +| Data Structures | Trees | [Is This a Binary Search Tree?](https://www.hackerrank.com/challenges/is-binary-search-tree) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Trees/Is%20This%20a%20Binary%20Search%20Tree/Solution.java) | +| Data Structures | Trees | [Square-Ten Tree](https://www.hackerrank.com/challenges/square-ten-tree) | Hard | Coming Soon! | +| Data Structures | Trees | [Balanced Forest](https://www.hackerrank.com/challenges/balanced-forest) | Hard | Coming Soon! | +| Data Structures | Balanced Trees | [Self Balancing Tree](https://www.hackerrank.com/challenges/self-balancing-tree) | Medium | Coming Soon! | +| Data Structures | Balanced Trees | [Array and simple queries](https://www.hackerrank.com/challenges/array-and-simple-queries) | Hard | Coming Soon! | +| Data Structures | Balanced Trees | [Median Updates](https://www.hackerrank.com/challenges/median) | Hard | Coming Soon! | +| Data Structures | Stacks | [Maximum Element](https://www.hackerrank.com/challenges/maximum-element) | Easy | Coming Soon! | +| Data Structures | Stacks | [Balanced Brackets](https://www.hackerrank.com/challenges/balanced-brackets) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Stacks/Balanced%20Brackets/Solution.java) | +| Data Structures | Stacks | [Largest Rectangle](https://www.hackerrank.com/challenges/largest-rectangle) | Hard | Coming Soon! | +| Data Structures | Stacks | [Simple Text Editor](https://www.hackerrank.com/challenges/simple-text-editor) | Medium | Coming Soon! | +| Data Structures | Stacks | [Equal Stacks](https://www.hackerrank.com/challenges/equal-stacks) | Easy | Coming Soon! | +| Data Structures | Stacks | [Poisonous Plants](https://www.hackerrank.com/challenges/poisonous-plants) | Hard | Coming Soon! | +| Data Structures | Stacks | [AND xor OR](https://www.hackerrank.com/challenges/and-xor-or) | Hard | Coming Soon! | +| Data Structures | Stacks | [Waiter](https://www.hackerrank.com/challenges/waiter) | Medium | Coming Soon! | +| Data Structures | Queues | [Queue using Two Stacks](https://www.hackerrank.com/challenges/queue-using-two-stacks) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Queues/Queue%20using%20Two%20Stacks/Solution.java) | +| Data Structures | Queues | [Castle on the Grid](https://www.hackerrank.com/challenges/castle-on-the-grid) | Medium | Coming Soon! | +| Data Structures | Queues | [Down to Zero II](https://www.hackerrank.com/challenges/down-to-zero-ii) | Medium | Coming Soon! | +| Data Structures | Queues | [Truck Tour](https://www.hackerrank.com/challenges/truck-tour) | Hard | Coming Soon! | +| Data Structures | Queues | [Queries with Fixed Length](https://www.hackerrank.com/challenges/queries-with-fixed-length) | Hard | Coming Soon! | +| Data Structures | Heap | [QHEAP1](https://www.hackerrank.com/challenges/qheap1) | Easy | Coming Soon! | +| Data Structures | Heap | [Jesse and Cookies](https://www.hackerrank.com/challenges/jesse-and-cookies) | Easy | Coming Soon! | +| Data Structures | Heap | [Find the Running Median](https://www.hackerrank.com/challenges/find-the-running-median) | Hard | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Heap/Find%20the%20Running%20Median/Solution.java) | +| Data Structures | Heap | [Minimum Average Waiting Time](https://www.hackerrank.com/challenges/minimum-average-waiting-time) | Hard | Coming Soon! | +| Data Structures | Disjoint Set | [Merging Communities](https://www.hackerrank.com/challenges/merging-communities) | Hard | Coming Soon! | +| Data Structures | Disjoint Set | [Components in a graph](https://www.hackerrank.com/challenges/components-in-graph) | Medium | Coming Soon! | +| Data Structures | Disjoint Set | [Kundu and Tree](https://www.hackerrank.com/challenges/kundu-and-tree) | Hard | Coming Soon! | +| Data Structures | Disjoint Set | [Super Maximum Cost Queries](https://www.hackerrank.com/challenges/maximum-cost-queries) | Hard | Coming Soon! | +| Data Structures | Multiple Choice | [Data Structures MCQ 1](https://www.hackerrank.com/challenges/how-well-do-you-know-trees) | Multiple Choice | Coming Soon! | +| Data Structures | Multiple Choice | [Data Structures MCQ 2](https://www.hackerrank.com/challenges/are-you-an-expert-on-data-structures) | Multiple Choice | Coming Soon! | +| Data Structures | Multiple Choice | [Data Structures MCQ 3](https://www.hackerrank.com/challenges/are-you-an-expert-on-data-structures-1) | Multiple Choice | Coming Soon! | +| Data Structures | Trie | [Contacts](https://www.hackerrank.com/challenges/contacts) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Trie/Contacts/Solution.java) | +| Data Structures | Trie | [No Prefix Set](https://www.hackerrank.com/challenges/no-prefix-set) | Hard | Coming Soon! | +| Data Structures | Advanced | [Kindergarten Adventures](https://www.hackerrank.com/challenges/kindergarten-adventures) | Medium | Coming Soon! | +| Data Structures | Advanced | [Cube Summation](https://www.hackerrank.com/challenges/cube-summation) | Hard | Coming Soon! | +| Data Structures | Advanced | [Mr. X and His Shots](https://www.hackerrank.com/challenges/x-and-his-shots) | Medium | Coming Soon! | +| Data Structures | Advanced | [Direct Connections](https://www.hackerrank.com/challenges/direct-connections) | Hard | Coming Soon! | +| Data Structures | Advanced | [Subsequence Weighting](https://www.hackerrank.com/challenges/subsequence-weighting) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Jim and the Skyscrapers](https://www.hackerrank.com/challenges/jim-and-the-skyscrapers) | Medium | Coming Soon! | +| Data Structures | Advanced | [Counting On a Tree](https://www.hackerrank.com/challenges/counting-on-a-tree) | Expert | Coming Soon! | +| Data Structures | Advanced | [Unique Colors](https://www.hackerrank.com/challenges/unique-colors) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Self-Driving Bus](https://www.hackerrank.com/challenges/self-driving-bus) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Fibonacci Numbers Tree](https://www.hackerrank.com/challenges/fibonacci-numbers-tree) | Expert | Coming Soon! | +| Data Structures | Advanced | [Functional Palindromes](https://www.hackerrank.com/challenges/functional-palindromes) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Lazy White Falcon](https://www.hackerrank.com/challenges/lazy-white-falcon) | Hard | Coming Soon! | +| Data Structures | Advanced | [Ticket to Ride](https://www.hackerrank.com/challenges/ticket-to-ride) | Expert | Coming Soon! | +| Data Structures | Advanced | [Heavy Light White Falcon](https://www.hackerrank.com/challenges/heavy-light-white-falcon) | Hard | Coming Soon! | +| Data Structures | Advanced | [Sum of the Maximums](https://www.hackerrank.com/challenges/little-alexey-and-sum-of-maximums) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Heavy Light 2 White Falcon](https://www.hackerrank.com/challenges/heavy-light-2-white-falcon) | Hard | Coming Soon! | +| Data Structures | Advanced | [Library Query](https://www.hackerrank.com/challenges/library-query) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Starfleet](https://www.hackerrank.com/challenges/starfleet) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Almost Equal - Advanced](https://www.hackerrank.com/challenges/almost-equal-advanced) | Expert | Coming Soon! | +| Data Structures | Advanced | [Almost sorted interval](https://www.hackerrank.com/challenges/almost-sorted-interval) | Expert | Coming Soon! | +| Data Structures | Advanced | [Burger Happiness](https://www.hackerrank.com/challenges/burger-happiness) | Hard | Coming Soon! | +| Data Structures | Advanced | [Roy and alpha-beta trees](https://www.hackerrank.com/challenges/roy-and-alpha-beta-trees) | Hard | Coming Soon! | +| Data Structures | Advanced | [Coloring Tree](https://www.hackerrank.com/challenges/coloring-tree) | Hard | Coming Soon! | +| Data Structures | Advanced | [Recalling Early Days GP with Trees](https://www.hackerrank.com/challenges/recalling-early-days-gp-with-trees) | Hard | Coming Soon! | +| Data Structures | Advanced | [Swaps and Sum](https://www.hackerrank.com/challenges/swaps-and-sum) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Arithmetic Progressions](https://www.hackerrank.com/challenges/arithmetic-progressions) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Coolguy and Two Subsequences](https://www.hackerrank.com/challenges/coolguy-and-two-subsequences) | Advanced | Coming Soon! | +| Data Structures | Advanced | [White Falcon And Tree](https://www.hackerrank.com/challenges/white-falcon-and-tree) | Hard | Coming Soon! | +| Data Structures | Advanced | [Subtrees And Paths](https://www.hackerrank.com/challenges/subtrees-and-paths) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Triplets](https://www.hackerrank.com/challenges/triplets) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Beautiful Segments](https://www.hackerrank.com/challenges/beautiful-segments) | Expert | Coming Soon! | +| Data Structures | Advanced | [Divisibility](https://www.hackerrank.com/challenges/ab0) | Expert | Coming Soon! | +| Data Structures | Advanced | [BST maintenance](https://www.hackerrank.com/challenges/bst-maintenance) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Find Maximum Index Product](https://www.hackerrank.com/challenges/find-maximum-index-product) | Medium | Coming Soon! | +| Data Structures | Advanced | [Taxicab Driver's Problem](https://www.hackerrank.com/challenges/taxicab-drivers-problem) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Jaggu Playing with Balloons](https://www.hackerrank.com/challenges/jagia-playing-with-numbers) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Dynamic Summation](https://www.hackerrank.com/challenges/dynamic-summation) | Hard | Coming Soon! | +| Data Structures | Advanced | [Two Array Problem](https://www.hackerrank.com/challenges/weird-queries) | Hard | Coming Soon! | +| Data Structures | Advanced | [Rooted Tree](https://www.hackerrank.com/challenges/rooted-tree) | Hard | Coming Soon! | +| Data Structures | Advanced | [The crazy helix](https://www.hackerrank.com/challenges/helix) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Network administration](https://www.hackerrank.com/challenges/net-admin) | Hard | Coming Soon! | +| Data Structures | Advanced | [Easy Addition](https://www.hackerrank.com/challenges/easy-addition) | Expert | Coming Soon! | +| Data Structures | Advanced | [Find the permutation](https://www.hackerrank.com/challenges/find-the-permutation) | Expert | Coming Soon! | +| Data Structures | Advanced | [Company Retreat](https://www.hackerrank.com/challenges/company-retreat) | Advanced | Coming Soon! | diff --git a/Data Structures/Stacks/Balanced Brackets/Solution.java b/Data Structures/Stacks/Balanced Brackets/Solution.java new file mode 100644 index 0000000..05e7785 --- /dev/null +++ b/Data Structures/Stacks/Balanced Brackets/Solution.java @@ -0,0 +1,45 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.Stack; +import java.util.HashMap; + +public class Solution { + + public static void main(String[] args) { + /* Create HashMap to match opening brackets with closing brackets */ + HashMap map = new HashMap<>(); + map.put('(', ')'); + map.put('[', ']'); + map.put('{', '}'); + + /* Test each expression for validity */ + Scanner scan = new Scanner(System.in); + int t = scan.nextInt(); + while (t-- > 0) { + String expression = scan.next(); + System.out.println(isBalanced(expression, map) ? "YES" : "NO" ); + } + scan.close(); + } + + public static boolean isBalanced(String expression, HashMap map) { + /* Odd length strings are not balanced */ + if ((expression.length() % 2) != 0) { + return false; + } + + Stack stack = new Stack<>(); + for (int i = 0; i < expression.length(); i++) { + Character ch = expression.charAt(i); + if (map.containsKey(ch)) { + stack.push(ch); + } else if (stack.isEmpty() || ch != map.get(stack.pop())) { + return false; + } + } + return stack.isEmpty(); + } +} diff --git a/Data Structures/Trees/Is This a Binary Search Tree/Solution.java b/Data Structures/Trees/Is This a Binary Search Tree/Solution.java new file mode 100644 index 0000000..e740f4d --- /dev/null +++ b/Data Structures/Trees/Is This a Binary Search Tree/Solution.java @@ -0,0 +1,26 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +/* Hidden stub code will pass a root argument to the function below. + +The Node class is defined as follows: + class Node { + int data; + Node left; + Node right; + } +*/ + +boolean checkBST(Node root) { + return checkBST(root, 0, 10000); // range of values in problem +} + +boolean checkBST(Node node, int min, int max) { + if (node == null) { + return true; + } else if (node.data < min || node.data > max) { + return false; + } + return checkBST(node.left, min, node.data - 1) && checkBST(node.right, node.data + 1, max); +} diff --git a/Data Structures/Trie/Contacts/Solution.java b/Data Structures/Trie/Contacts/Solution.java new file mode 100644 index 0000000..f4db7d3 --- /dev/null +++ b/Data Structures/Trie/Contacts/Solution.java @@ -0,0 +1,65 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.HashMap; + +public class Solution { + + private static TrieNode root = new TrieNode(); + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + for(int a0 = 0; a0 < n; a0++) { + String op = scan.next(); + String contact = scan.next(); + if (op.equals("add")) { + add(contact); + } else if (op.equals("find")) { + System.out.println(find(contact)); + } + } + scan.close(); + } + + private static void add(String str) { + TrieNode curr = root; + for (int i = 0; i < str.length(); i++) { + Character ch = str.charAt(i); + + if ( ! curr.children.containsKey(ch)) { + curr.addChild(ch); + } + curr = curr.children.get(ch); + curr.size++; // each time we visit a node (while adding letters), we increment this. + } + } + + private static int find(String str) { + TrieNode curr = root; + + /* Traverse down tree to end of our prefix */ + for (int i = 0; i < str.length(); i++) { + Character ch = str.charAt(i); + if ( ! curr.children.containsKey(ch)) { + return 0; + } else { + curr = curr.children.get(ch); + } + } + + return curr.size; + } + + /* This implementation is somewhat based off the tutorial video in this problem */ + public static class TrieNode { + public HashMap children = new HashMap<>(); + public int size = 0; // this was the main trick to decrease runtime to pass tests. + + public void addChild(Character ch) { + children.put(ch, new TrieNode()); + } + } +} diff --git a/Java/Data Structures/Java BitSet/Solution.java b/Java/Data Structures/Java BitSet/Solution.java new file mode 100644 index 0000000..a708b76 --- /dev/null +++ b/Java/Data Structures/Java BitSet/Solution.java @@ -0,0 +1,62 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.BitSet; + +public class Solution { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int N = scan.nextInt(); + int M = scan.nextInt(); + BitSet B1 = new BitSet(N); + BitSet B2 = new BitSet(N); + while (M-- > 0) { + String str = scan.next(); + int a = scan.nextInt(); + int b = scan.nextInt(); + switch (str) { + case "AND": + if (a == 1) { + B1.and(B2); + } else { + B2.and(B1); + } + break; + case "OR": + if (a == 1) { + B1.or(B2); + } else { + B2.or(B1); + } + break; + case "XOR": + if (a == 1) { + B1.xor(B2); + } else { + B2.xor(B1); + } + break; + case "FLIP": + if (a == 1) { + B1.flip(b); + } else { + B2.flip(b); + } + break; + case "SET": + if (a == 1) { + B1.set(b); + } else { + B2.set(b); + } + break; + default: + break; + } + System.out.println(B1.cardinality() + " " + B2.cardinality()); + } + } +} + diff --git a/Java/Data Structures/Java Comparator/Solution.java b/Java/Data Structures/Java Comparator/Solution.java new file mode 100644 index 0000000..bbd30b9 --- /dev/null +++ b/Java/Data Structures/Java Comparator/Solution.java @@ -0,0 +1,47 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.*; + +class Checker implements Comparator { + @Override + public int compare(Player p1, Player p2) { + if (p1.score == p2.score) { + return p1.name.compareTo(p2.name); + } else { + return p2.score - p1.score; + } + } +} + +class Player{ + String name; + int score; + + Player(String name, int score){ + this.name = name; + this.score = score; + } +} + +class Solution { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + + Player[] player = new Player[n]; + Checker checker = new Checker(); + + for(int i = 0; i < n; i++){ + player[i] = new Player(scan.next(), scan.nextInt()); + } + scan.close(); + + Arrays.sort(player, checker); + for(int i = 0; i < player.length; i++){ + System.out.printf("%s %s\n", player[i].name, player[i].score); + } + } +} diff --git a/Java/Data Structures/Java Dequeue/Solution.java b/Java/Data Structures/Java Dequeue/Solution.java new file mode 100644 index 0000000..e10ebd3 --- /dev/null +++ b/Java/Data Structures/Java Dequeue/Solution.java @@ -0,0 +1,55 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.Deque; +import java.util.ArrayDeque; +import java.util.HashMap; + +// O(n) runtime +// O(n) space complexity +public class test { + public static void main(String[] args) { + /* Create our data structures */ + Deque deque = new ArrayDeque<>(); + HashMap map = new HashMap<>(); + + /* Save first m entries */ + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + int m = scan.nextInt(); + for (int i = 0; i < m; i++) { + int num = scan.nextInt(); + deque.add(num); + if (map.containsKey(num)) { + map.put(num, map.get(num) + 1); + } else { + map.put(num, 1); + } + } + + /* Loop through remaining n-m entries */ + int max = map.size(); + for (int i = m; i < n; i++) { + /* Remove old value */ + int old = deque.remove(); + if (map.get(old) == 1) { + map.remove(old); + } else { + map.put(old, map.get(old) - 1); + } + /* Add new value */ + int num = scan.nextInt(); + deque.add(num); + if (map.containsKey(num)) { + map.put(num, map.get(num) + 1); + } else { + map.put(num, 1); + } + + max = Math.max(max, map.size()); + } + System.out.println(max); + } +} diff --git a/Java/Data Structures/Java Generics/Solution.java b/Java/Data Structures/Java Generics/Solution.java new file mode 100644 index 0000000..e862a1d --- /dev/null +++ b/Java/Data Structures/Java Generics/Solution.java @@ -0,0 +1,35 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.io.IOException; +import java.lang.reflect.Method; + +class Printer { + void printArray(T[] array) { + for (T item : array) { + System.out.println(item); + } + } +} + +public class Solution { + public static void main( String args[] ) { + Printer myPrinter = new Printer(); + Integer[] intArray = { 1, 2, 3 }; + String[] stringArray = {"Hello", "World"}; + myPrinter.printArray(intArray); + myPrinter.printArray(stringArray); + int count = 0; + + for (Method method : Printer.class.getDeclaredMethods()) { + String name = method.getName(); + + if(name.equals("printArray")) + count++; + } + + if(count > 1)System.out.println("Method overloading is not allowed!"); + + } +} diff --git a/Java/Data Structures/Java Hashset/Solution.java b/Java/Data Structures/Java Hashset/Solution.java new file mode 100644 index 0000000..a63110f --- /dev/null +++ b/Java/Data Structures/Java Hashset/Solution.java @@ -0,0 +1,31 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +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 s = new Scanner(System.in); + int t = s.nextInt(); + String [] pair_left = new String[t]; + String [] pair_right = new String[t]; + + for (int i = 0; i < t; i++) { + pair_left[i] = s.next(); + pair_right[i] = s.next(); + } + s.close(); + + HashSet set = new HashSet<>(t); + for (int i = 0; i < t; i++) { + set.add(pair_left[i] + " " + pair_right[i]); + System.out.println(set.size()); + } + } +} diff --git a/Java/Data Structures/Java List/Solution.java b/Java/Data Structures/Java List/Solution.java new file mode 100644 index 0000000..5cb505b --- /dev/null +++ b/Java/Data Structures/Java List/Solution.java @@ -0,0 +1,39 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.LinkedList; + +public class Solution { + public static void main(String[] args) { + /* Create and fill Linked List of Integers */ + Scanner scan = new Scanner(System.in); + int N = scan.nextInt(); + LinkedList list = new LinkedList<>(); + for (int i = 0; i < N; i++) { + int value = scan.nextInt(); + list.add(value); + } + + /* Perfrom queries on Linked List */ + int Q = scan.nextInt(); + for (int i = 0; i < Q; i++) { + String action = scan.next(); + if (action.equals("Insert")) { + int index = scan.nextInt(); + int value = scan.nextInt(); + list.add(index, value); + } else { // "Delete" + int index = scan.nextInt(); + list.remove(index); + } + } + scan.close(); + + /* Print our updated Linked List */ + for (Integer num : list) { + System.out.print(num + " "); + } + } +} diff --git a/Java/Data Structures/Java Map/Solution.java b/Java/Data Structures/Java Map/Solution.java new file mode 100644 index 0000000..cb0e87c --- /dev/null +++ b/Java/Data Structures/Java Map/Solution.java @@ -0,0 +1,35 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.HashMap; + +/* BufferedReader is used instead of Scanner since it's faster and + won't time out on HackerRank test cases when using Java8 */ +class Solution { + public static void main(String [] args) throws Exception { + /* Read input and save as entries in a HashMap */ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.valueOf(br.readLine()); + HashMap map = new HashMap<>(); + while (n-- > 0) { + String name = br.readLine(); + int phone = Integer.valueOf(br.readLine()); + map.put(name, phone); + } + + /* Read each query and check if its in our HashMap */ + String s; + while((s = br.readLine()) != null) { + if (map.containsKey(s)) { + System.out.println(s + "=" + map.get(s)); + } else { + System.out.println("Not found"); + } + } + + br.close(); + } +} diff --git a/Java/Data Structures/Java Sort/Solution.java b/Java/Data Structures/Java Sort/Solution.java new file mode 100644 index 0000000..dbc28f6 --- /dev/null +++ b/Java/Data Structures/Java Sort/Solution.java @@ -0,0 +1,68 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +class Student{ + private int id; + private String fname; + private double cgpa; + public Student(int id, String fname, double cgpa) { + super(); + this.id = id; + this.fname = fname; + this.cgpa = cgpa; + } + public int getId() { + return id; + } + public String getFname() { + return fname; + } + public double getCgpa() { + return cgpa; + } +} + +public class Solution { + public static void main(String[] args){ + Scanner scan = new Scanner(System.in); + int testCases = Integer.parseInt(scan.nextLine()); + + List studentList = new ArrayList(); + while (testCases-- > 0) { + int id = scan.nextInt(); + String fname = scan.next(); + double cgpa = scan.nextDouble(); + + Student st = new Student(id, fname, cgpa); + studentList.add(st); + } + scan.close(); + + Collections.sort(studentList, new StudentComparator()); + + for (Student st: studentList) { + System.out.println(st.getFname()); + } + } +} + +class StudentComparator implements Comparator { + double epsilon = 0.001; // since we shouldn't use "==" with doubles + @Override + public int compare(Student s1, Student s2) { + if (Math.abs(s1.getCgpa() - s2.getCgpa()) > epsilon) { + return s1.getCgpa() < s2.getCgpa() ? 1 : -1; // descending order + } else if (!s1.getFname().equals(s2.getFname())) { + return s1.getFname().compareTo(s2.getFname()); + } else { + return s1.getId() - s2.getId(); + } + } +} diff --git a/Java/Data Structures/Java Stack/Solution.java b/Java/Data Structures/Java Stack/Solution.java new file mode 100644 index 0000000..9da5d26 --- /dev/null +++ b/Java/Data Structures/Java Stack/Solution.java @@ -0,0 +1,44 @@ +// Author: Rodney Shaghoulian +// Github: github.com/rshaghoulian +// HackerRank: hackerrank.com/rshaghoulian + +import java.util.Scanner; +import java.util.Stack; +import java.util.HashMap; + +class Solution { + + public static void main(String[] args) { + /* Create HashMap to match opening brackets with closing brackets */ + HashMap map = new HashMap<>(); + map.put('(', ')'); + map.put('[', ']'); + map.put('{', '}'); + + /* Test each expression for validity */ + Scanner scan = new Scanner(System.in); + while (scan.hasNext()) { + String expression = scan.next(); + System.out.println(isBalanced(expression, map) ? "true" : "false" ); + } + scan.close(); + } + + public static boolean isBalanced(String expression, HashMap map) { + /* Odd length strings are not balanced */ + if ((expression.length() % 2) != 0) { + return false; + } + + Stack stack = new Stack<>(); + for (int i = 0; i < expression.length(); i++) { + Character ch = expression.charAt(i); + if (map.containsKey(ch)) { + stack.push(ch); + } else if (stack.isEmpty() || ch != map.get(stack.pop())) { + return false; + } + } + return stack.isEmpty(); + } +} diff --git a/Java/README.md b/Java/README.md index 0bd1c89..64038e1 100644 --- a/Java/README.md +++ b/Java/README.md @@ -1,26 +1,69 @@ ## Java -| Domain | Subdomain | Challenge | Difficulty | Solution | -|:------:|:---------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:----------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------:| -| Java | Introduction | [Welcome to Java!](https://www.hackerrank.com/challenges/welcome-to-java) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Welcome%20to%20Java!/Solution.java) | -| Java | Introduction | [Java Stdin and Stdout I](https://www.hackerrank.com/challenges/java-stdin-and-stdout-1) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Stdin%20and%20Stdout%20I/Solution.java) | -| Java | Introduction | [Java If-Else](https://www.hackerrank.com/challenges/java-if-else) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20If-Else/Solution.java) | -| Java | Introduction | [Java Stdin and Stdout II](https://www.hackerrank.com/challenges/java-stdin-stdout) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Stdin%20and%20Stdout%20II/Solution.java) | -| Java | Introduction | [Java Output Formatting](https://www.hackerrank.com/challenges/java-output-formatting) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Output%20Formatting/Solution.java) | -| Java | Introduction | [Java Loops I](https://www.hackerrank.com/challenges/java-loops-i) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Loops%20I/Solution.java) | -| Java | Introduction | [Java Loops II](https://www.hackerrank.com/challenges/java-loops) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Loops%20II/Solution.java) | -| Java | Introduction | [Java Datatypes](https://www.hackerrank.com/challenges/java-datatypes) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Datatypes/Solution.java) | -| Java | Introduction | [Java End-of-file](https://www.hackerrank.com/challenges/java-end-of-file) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20End-of-file/Solution.java) | -| Java | Introduction | [Java Static Initializer Block](https://www.hackerrank.com/challenges/java-static-initializer-block) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Static%20Initializer%20Block/Solution.java) | -| Java | Introduction | [Java Int to String](https://www.hackerrank.com/challenges/java-int-to-string) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Int%20to%20String/Solution.java) | -| Java | Introduction | [Java Data and Time](https://www.hackerrank.com/challenges/java-date-and-time) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Date%20and%20Time/Solution.java) | -| Java | Introduction | [Java Currency Formatter](https://www.hackerrank.com/challenges/java-currency-formatter) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Currency%20Formatter/Solution.java) | -| Java | Strings | [Java Strings Introduction](https://www.hackerrank.com/challenges/java-strings-introduction) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Strings%20Introduction/Solution.java) | -| Java | Strings | [Java Substring](https://www.hackerrank.com/challenges/java-substring) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Substring/Solution.java) | -| Java | Strings | [Java String Compare](https://www.hackerrank.com/challenges/java-string-compare) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20String%20Compare/Solution.java) | -| Java | Strings | [Java String Reverse](https://www.hackerrank.com/challenges/java-string-reverse) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20String%20Reverse/Solution.java) | -| Java | Strings | [Java Anagrams](https://www.hackerrank.com/challenges/java-anagrams) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Anagrams/Solution.java) | -| Java | Strings | [Java String Tokens](https://www.hackerrank.com/challenges/java-string-tokens) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20String%20Tokens/Solution.java) | -| Java | Strings | [Pattern Syntax Checker](https://www.hackerrank.com/challenges/pattern-syntax-checker) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Pattern%20Syntax%20Checker/Solution.java) | -| Java | Strings | [Java Regex](https://www.hackerrank.com/challenges/java-regex) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Regex/Solution.java) | -| Java | Strings | [Java Regex 2 - Duplicate Words](https://www.hackerrank.com/challenges/duplicate-word) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Regex%202%20-%20Duplicate%20Words/Solution.java) | +| Domain | Subdomain | Challenge | Difficulty | Solution | +|:------:|:---------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:----------:|:------------------------------------------------------------------------------------------------------------------------------------------------------:| +| Java | Introduction | [Welcome to Java!](https://www.hackerrank.com/challenges/welcome-to-java) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Welcome%20to%20Java!/Solution.java) | +| Java | Introduction | [Java Stdin and Stdout I](https://www.hackerrank.com/challenges/java-stdin-and-stdout-1) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Stdin%20and%20Stdout%20I/Solution.java) | +| Java | Introduction | [Java If-Else](https://www.hackerrank.com/challenges/java-if-else) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20If-Else/Solution.java) | +| Java | Introduction | [Java Stdin and Stdout II](https://www.hackerrank.com/challenges/java-stdin-stdout) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Stdin%20and%20Stdout%20II/Solution.java) | +| Java | Introduction | [Java Output Formatting](https://www.hackerrank.com/challenges/java-output-formatting) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Output%20Formatting/Solution.java) | +| Java | Introduction | [Java Loops I](https://www.hackerrank.com/challenges/java-loops-i) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Loops%20I/Solution.java) | +| Java | Introduction | [Java Loops II](https://www.hackerrank.com/challenges/java-loops) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Loops%20II/Solution.java) | +| Java | Introduction | [Java Datatypes](https://www.hackerrank.com/challenges/java-datatypes) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Datatypes/Solution.java) | +| Java | Introduction | [Java End-of-file](https://www.hackerrank.com/challenges/java-end-of-file) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20End-of-file/Solution.java) | +| Java | Introduction | [Java Static Initializer Block](https://www.hackerrank.com/challenges/java-static-initializer-block) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Static%20Initializer%20Block/Solution.java) | +| Java | Introduction | [Java Int to String](https://www.hackerrank.com/challenges/java-int-to-string) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Int%20to%20String/Solution.java) | +| Java | Introduction | [Java Data and Time](https://www.hackerrank.com/challenges/java-date-and-time) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Date%20and%20Time/Solution.java) | +| Java | Introduction | [Java Currency Formatter](https://www.hackerrank.com/challenges/java-currency-formatter) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Introduction/Java%20Currency%20Formatter/Solution.java) | +| Java | Strings | [Java Strings Introduction](https://www.hackerrank.com/challenges/java-strings-introduction) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Strings%20Introduction/Solution.java) | +| Java | Strings | [Java Substring](https://www.hackerrank.com/challenges/java-substring) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Substring/Solution.java) | +| Java | Strings | [Java String Compare](https://www.hackerrank.com/challenges/java-string-compare) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20String%20Compare/Solution.java) | +| Java | Strings | [Java String Reverse](https://www.hackerrank.com/challenges/java-string-reverse) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20String%20Reverse/Solution.java) | +| Java | Strings | [Java Anagrams](https://www.hackerrank.com/challenges/java-anagrams) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Anagrams/Solution.java) | +| Java | Strings | [Java String Tokens](https://www.hackerrank.com/challenges/java-string-tokens) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20String%20Tokens/Solution.java) | +| Java | Strings | [Pattern Syntax Checker](https://www.hackerrank.com/challenges/pattern-syntax-checker) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Pattern%20Syntax%20Checker/Solution.java) | +| Java | Strings | [Java Regex](https://www.hackerrank.com/challenges/java-regex) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Regex/Solution.java) | +| Java | Strings | [Java Regex 2 - Duplicate Words](https://www.hackerrank.com/challenges/duplicate-word) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Regex%202%20-%20Duplicate%20Words/Solution.java) | +| Java | Strings | [Java Regex 3 - Username Checker](https://www.hackerrank.com/challenges/valid-username-checker) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Java%20Regex%203%20-%20Username%20Checker/Solution.java) | +| Java | Strings | [Tag Content Extractor](https://www.hackerrank.com/challenges/tag-content-extractor) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Strings/Tag%20Content%20Extractor/Solution.java) | +| Java | BigNumber | [Java BigInteger](https://www.hackerrank.com/challenges/java-biginteger) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/BigNumber/Java%20BigInteger/Solution.java) | +| Java | BigNumber | [Java BigDecimal](https://www.hackerrank.com/challenges/java-bigdecimal) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/BigNumber/Java%20BigDecimal/Solution.java) | +| Java | BigNumber | [Java Primality Test](https://www.hackerrank.com/challenges/java-primality-test) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/BigNumber/Java%20Primality%20Test/Solution.java) | +| Java | Data Structures | [Java 1D Array](https://www.hackerrank.com/challenges/java-1d-array-introduction) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%201D%20Array/Solution.java) | +| Java | Data Structures | [Java 2D Array](https://www.hackerrank.com/challenges/java-2d-array) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%202D%20Array/Solution.java) | +| Java | Data Structures | [Java Subarray](https://www.hackerrank.com/challenges/java-negative-subarray) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Subarray/Solution.java) | +| Java | Data Structures | [Java Arraylist](https://www.hackerrank.com/challenges/java-arraylist) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20ArrayList/Solution.java) | +| Java | Data Structures | [Java 1D Array (Part 2)](https://www.hackerrank.com/challenges/java-1d-array) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%201D%20Array%20(Part%202)/Solution.java) | +| Java | Data Structures | [Java List](https://www.hackerrank.com/challenges/java-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20List/Solution.java) | +| Java | Data Structures | [Java Map](https://www.hackerrank.com/challenges/phone-book) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Map/Solution.java) | +| Java | Data Structures | [Java Stack](https://www.hackerrank.com/challenges/java-stack) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Stack/Solution.java) | +| Java | Data Structures | [Java Hashset](https://www.hackerrank.com/challenges/java-hashset) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Hashset/Solution.java) | +| Java | Data Structures | [Java Generics](https://www.hackerrank.com/challenges/java-generics) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Generics/Solution.java) | +| Java | Data Structures | [Java Comparator](https://www.hackerrank.com/challenges/java-comparator) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Comparator/Solution.java) | +| Java | Data Structures | [Java Sort](https://www.hackerrank.com/challenges/java-sort) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Sort/Solution.java) | +| Java | Data Structures | [Java Dequeue](https://www.hackerrank.com/challenges/java-dequeue) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Dequeue/Solution.java) | +| Java | Data Structures | [Java BitSet](https://www.hackerrank.com/challenges/java-bitset) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20BitSet/Solution.java) | +| Java | Data Structures | [Java Priority Queue](https://www.hackerrank.com/challenges/java-priority-queue) | Medium | Coming Soon! | +| Java | Object Oriented Programming | [Java Inheritance I](https://www.hackerrank.com/challenges/java-inheritance-1) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Inheritance II](https://www.hackerrank.com/challenges/java-inheritance-2) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Abstract Class](https://www.hackerrank.com/challenges/java-abstract-class) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Interface](https://www.hackerrank.com/challenges/java-interface) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Method Overriding](https://www.hackerrank.com/challenges/java-method-overriding) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Method Overriding 2 (Super Keyword)](https://www.hackerrank.com/challenges/java-method-overriding-2-super-keyword) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Instanceof keyword](https://www.hackerrank.com/challenges/java-instanceof-keyword) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Iterator](https://www.hackerrank.com/challenges/java-iterator) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Calculating Volume](https://www.hackerrank.com/challenges/calculating-volume) | Medium | Coming Soon! | +| Java | Exception Handling | [Java Exception Handling (Try-catch)](https://www.hackerrank.com/challenges/java-exception-handling-try-catch) | Easy | Coming Soon! | +| Java | Exception Handling | [Java Exception Handling](https://www.hackerrank.com/challenges/java-exception-handling) | Easy | Coming Soon! | +| Java | Advanced | [Java Varargs - Simple Addition](https://www.hackerrank.com/challenges/simple-addition-varargs) | Easy | Coming Soon! | +| Java | Advanced | [Java Reflection - Attributes](https://www.hackerrank.com/challenges/java-reflection-attributes) | Easy | Coming Soon! | +| Java | Advanced | [Can You Access](https://www.hackerrank.com/challenges/can-you-access) | Medium | Coming Soon! | +| Java | Advanced | [Prime Checker](https://www.hackerrank.com/challenges/prime-checker) | Medium | Coming Soon! | +| Java | Advanced | [Java Factory Pattern](https://www.hackerrank.com/challenges/java-factory) | Easy | Coming Soon! | +| Java | Advanced | [Java Singleton Pattern](https://www.hackerrank.com/challenges/java-singleton) | Easy | Coming Soon! | +| Java | Advanced | [Java Visitor Pattern](https://www.hackerrank.com/challenges/java-vistor-pattern) | Medium | Coming Soon! | +| Java | Advanced | [Java Annotations](https://www.hackerrank.com/challenges/java-annotations) | Medium | Coming Soon! | +| Java | Advanced | [Covariant Return Types](https://www.hackerrank.com/challenges/java-covariance) | Easy | Coming Soon! | +| Java | Advanced | [Java Lambda Expressions](https://www.hackerrank.com/challenges/java-lambda-expressions) | Medium | Coming Soon! | +| Java | Advanced | [Java MD5](https://www.hackerrank.com/challenges/java-md5) | Medium | Coming Soon! | +| Java | Advanced | [Java SHA-256](https://www.hackerrank.com/challenges/sha-256) | Medium | Coming Soon! | diff --git a/README.md b/README.md index 410cb2e..1633036 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,39 @@ My Java solutions to [HackerRank](https://www.hackerrank.com/) challenges | Java | Data Structures | [Java Subarray](https://www.hackerrank.com/challenges/java-negative-subarray) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Subarray/Solution.java) | | Java | Data Structures | [Java Arraylist](https://www.hackerrank.com/challenges/java-arraylist) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20ArrayList/Solution.java) | | Java | Data Structures | [Java 1D Array (Part 2)](https://www.hackerrank.com/challenges/java-1d-array) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%201D%20Array%20(Part%202)/Solution.java) | +| Java | Data Structures | [Java List](https://www.hackerrank.com/challenges/java-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20List/Solution.java) | +| Java | Data Structures | [Java Map](https://www.hackerrank.com/challenges/phone-book) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Map/Solution.java) | +| Java | Data Structures | [Java Stack](https://www.hackerrank.com/challenges/java-stack) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Stack/Solution.java) | +| Java | Data Structures | [Java Hashset](https://www.hackerrank.com/challenges/java-hashset) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Hashset/Solution.java) | +| Java | Data Structures | [Java Generics](https://www.hackerrank.com/challenges/java-generics) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Generics/Solution.java) | +| Java | Data Structures | [Java Comparator](https://www.hackerrank.com/challenges/java-comparator) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Comparator/Solution.java) | +| Java | Data Structures | [Java Sort](https://www.hackerrank.com/challenges/java-sort) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Sort/Solution.java) | +| Java | Data Structures | [Java Dequeue](https://www.hackerrank.com/challenges/java-dequeue) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20Dequeue/Solution.java) | +| Java | Data Structures | [Java BitSet](https://www.hackerrank.com/challenges/java-bitset) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Java/Data%20Structures/Java%20BitSet/Solution.java) | +| Java | Data Structures | [Java Priority Queue](https://www.hackerrank.com/challenges/java-priority-queue) | Medium | Coming Soon! | +| Java | Object Oriented Programming | [Java Inheritance I](https://www.hackerrank.com/challenges/java-inheritance-1) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Inheritance II](https://www.hackerrank.com/challenges/java-inheritance-2) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Abstract Class](https://www.hackerrank.com/challenges/java-abstract-class) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Interface](https://www.hackerrank.com/challenges/java-interface) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Method Overriding](https://www.hackerrank.com/challenges/java-method-overriding) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Method Overriding 2 (Super Keyword)](https://www.hackerrank.com/challenges/java-method-overriding-2-super-keyword) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Instanceof keyword](https://www.hackerrank.com/challenges/java-instanceof-keyword) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Java Iterator](https://www.hackerrank.com/challenges/java-iterator) | Easy | Coming Soon! | +| Java | Object Oriented Programming | [Calculating Volume](https://www.hackerrank.com/challenges/calculating-volume) | Medium | Coming Soon! | +| Java | Exception Handling | [Java Exception Handling (Try-catch)](https://www.hackerrank.com/challenges/java-exception-handling-try-catch) | Easy | Coming Soon! | +| Java | Exception Handling | [Java Exception Handling](https://www.hackerrank.com/challenges/java-exception-handling) | Easy | Coming Soon! | +| Java | Advanced | [Java Varargs - Simple Addition](https://www.hackerrank.com/challenges/simple-addition-varargs) | Easy | Coming Soon! | +| Java | Advanced | [Java Reflection - Attributes](https://www.hackerrank.com/challenges/java-reflection-attributes) | Easy | Coming Soon! | +| Java | Advanced | [Can You Access](https://www.hackerrank.com/challenges/can-you-access) | Medium | Coming Soon! | +| Java | Advanced | [Prime Checker](https://www.hackerrank.com/challenges/prime-checker) | Medium | Coming Soon! | +| Java | Advanced | [Java Factory Pattern](https://www.hackerrank.com/challenges/java-factory) | Easy | Coming Soon! | +| Java | Advanced | [Java Singleton Pattern](https://www.hackerrank.com/challenges/java-singleton) | Easy | Coming Soon! | +| Java | Advanced | [Java Visitor Pattern](https://www.hackerrank.com/challenges/java-vistor-pattern) | Medium | Coming Soon! | +| Java | Advanced | [Java Annotations](https://www.hackerrank.com/challenges/java-annotations) | Medium | Coming Soon! | +| Java | Advanced | [Covariant Return Types](https://www.hackerrank.com/challenges/java-covariance) | Easy | Coming Soon! | +| Java | Advanced | [Java Lambda Expressions](https://www.hackerrank.com/challenges/java-lambda-expressions) | Medium | Coming Soon! | +| Java | Advanced | [Java MD5](https://www.hackerrank.com/challenges/java-md5) | Medium | Coming Soon! | +| Java | Advanced | [Java SHA-256](https://www.hackerrank.com/challenges/sha-256) | Medium | Coming Soon! | ## 30 Days of Code @@ -136,3 +169,116 @@ My Java solutions to [HackerRank](https://www.hackerrank.com/) challenges | Algorithms | Warmup | [Time Conversion](https://www.hackerrank.com/challenges/time-conversion) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Time%20Conversion/Solution.java) | | Algorithms | Warmup | [Circular Array Rotation](https://www.hackerrank.com/challenges/circular-array-rotation) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Warmup/Circular%20Array%20Rotation/Solution.java) | | Algorithms | Implementation | [Mini-max Sum](https://www.hackerrank.com/challenges/mini-max-sum) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Algorithms/Implementation/Mini-Max%20Sum/Solution.java) | + + +## Data Structures + +| Domain | Subdomain | Challenge | Difficulty | Solution | +|:---------------:|:---------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| Data Structures | Arrays | [Arrays - DS](https://www.hackerrank.com/challenges/arrays-ds) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/Arrays%20-%20DS/Solution.java) | +| Data Structures | Arrays | [2D Array - DS](https://www.hackerrank.com/challenges/2d-array) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/2D%20Array%20-%20DS/Solution.java) | +| Data Structures | Arrays | [Dynamic Array](https://www.hackerrank.com/challenges/dynamic-array) | Easy | Coming Soon! | +| Data Structures | Arrays | [Left Rotation](https://www.hackerrank.com/challenges/array-left-rotation) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/Left%20Rotation/Solution.java) | +| Data Structures | Arrays | [Sparse Arrays](https://www.hackerrank.com/challenges/sparse-arrays) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Arrays/Sparse%20Arrays/Solution.java) | +| Data Structures | Arrays | [Algorithmic Crush](https://www.hackerrank.com/challenges/crush) | Hard | Coming Soon! | +| Data Structures | Linked List | [Print the Elements of a Linked List](https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Print%20the%20Elements%20of%20a%20Linked%20List/Solution.java) | +| Data Structures | Linked List | [Insert a Node at the Tail of a Linked List](https://www.hackerrank.com/challenges/insert-a-node-at-the-tail-of-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Insert%20a%20Node%20at%20the%20Tail%20of%20a%20Linked%20List/Solution.java) | +| Data Structures | Linked List | [Insert a node at the head of a linked list](https://www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Insert%20a%20node%20at%20the%20head%20of%20a%20linked%20list/Solution.java) | +| Data Structures | Linked List | [Insert a node at a specific position in a linked list](https://www.hackerrank.com/challenges/insert-a-node-at-a-specific-position-in-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Insert%20a%20node%20at%20a%20specific%20position%20in%20a%20linked%20list/Solution.java) | +| Data Structures | Linked List | [Delete a Node](https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Delete%20a%20Node/Solution.java) | +| Data Structures | Linked List | [Print in Reverse](https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list-in-reverse) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Print%20in%20Reverse/Solution.java) | +| Data Structures | Linked List | [Reverse a linked list](https://www.hackerrank.com/challenges/reverse-a-linked-list) | Easy | Coming Soon! | +| Data Structures | Linked List | [Compare two linked lists](https://www.hackerrank.com/challenges/compare-two-linked-lists) | Easy | Coming Soon! | +| Data Structures | Linked List | [Merge two sorted linked lists](https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists) | Easy | Coming Soon! | +| Data Structures | Linked List | [Get Node Value](https://www.hackerrank.com/challenges/get-the-value-of-the-node-at-a-specific-position-from-the-tail) | Easy | Coming Soon! | +| Data Structures | Linked List | [Delete duplicate-value nodes from a sorted linked list](https://www.hackerrank.com/challenges/delete-duplicate-value-nodes-from-a-sorted-linked-list) | Easy | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Delete%20duplicate-value%20nodes%20from%20a%20sorted%20linked%20list/Solution.java) | +| Data Structures | Linked List | [Cycle Detection](https://www.hackerrank.com/challenges/detect-whether-a-linked-list-contains-a-cycle) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Linked%20Lists/Cycle%20Detection/Solution.java) | +| Data Structures | Linked List | [Find Merge Point of Two Lists](https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists) | Easy | Coming Soon! | +| Data Structures | Linked List | [Inserting a Node Into a Sorted Doubly Linked List](https://www.hackerrank.com/challenges/insert-a-node-into-a-sorted-doubly-linked-list) | Easy | Coming Soon! | +| Data Structures | Linked List | [Reverse a doubly linked list](https://www.hackerrank.com/challenges/reverse-a-doubly-linked-list) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Preorder Traversal](https://www.hackerrank.com/challenges/tree-preorder-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Postorder Traversal](https://www.hackerrank.com/challenges/tree-postorder-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Inorder Traversal](https://www.hackerrank.com/challenges/tree-inorder-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Height of a Binary Tree](https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Top View](https://www.hackerrank.com/challenges/tree-top-view) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Level Order Traversal](https://www.hackerrank.com/challenges/tree-level-order-traversal) | Easy | Coming Soon! | +| Data Structures | Trees | [Binary Search Tree: Insertion](https://www.hackerrank.com/challenges/binary-search-tree-insertion) | Easy | Coming Soon! | +| Data Structures | Trees | [Tree: Huffman Decoding](https://www.hackerrank.com/challenges/tree-huffman-decoding) | Medium | Coming Soon! | +| Data Structures | Trees | [Binary Search Tree: Lowest Common Ancestor](https://www.hackerrank.com/challenges/binary-search-tree-lowest-common-ancestor) | Easy | Coming Soon! | +| Data Structures | Trees | [Swap Nodes [Algo]](https://www.hackerrank.com/challenges/swap-nodes-algo) | Medium | Coming Soon! | +| Data Structures | Trees | [Is This a Binary Search Tree?](https://www.hackerrank.com/challenges/is-binary-search-tree) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Trees/Is%20This%20a%20Binary%20Search%20Tree/Solution.java) | +| Data Structures | Trees | [Square-Ten Tree](https://www.hackerrank.com/challenges/square-ten-tree) | Hard | Coming Soon! | +| Data Structures | Trees | [Balanced Forest](https://www.hackerrank.com/challenges/balanced-forest) | Hard | Coming Soon! | +| Data Structures | Balanced Trees | [Self Balancing Tree](https://www.hackerrank.com/challenges/self-balancing-tree) | Medium | Coming Soon! | +| Data Structures | Balanced Trees | [Array and simple queries](https://www.hackerrank.com/challenges/array-and-simple-queries) | Hard | Coming Soon! | +| Data Structures | Balanced Trees | [Median Updates](https://www.hackerrank.com/challenges/median) | Hard | Coming Soon! | +| Data Structures | Stacks | [Maximum Element](https://www.hackerrank.com/challenges/maximum-element) | Easy | Coming Soon! | +| Data Structures | Stacks | [Balanced Brackets](https://www.hackerrank.com/challenges/balanced-brackets) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Stacks/Balanced%20Brackets/Solution.java) | +| Data Structures | Stacks | [Largest Rectangle](https://www.hackerrank.com/challenges/largest-rectangle) | Hard | Coming Soon! | +| Data Structures | Stacks | [Simple Text Editor](https://www.hackerrank.com/challenges/simple-text-editor) | Medium | Coming Soon! | +| Data Structures | Stacks | [Equal Stacks](https://www.hackerrank.com/challenges/equal-stacks) | Easy | Coming Soon! | +| Data Structures | Stacks | [Poisonous Plants](https://www.hackerrank.com/challenges/poisonous-plants) | Hard | Coming Soon! | +| Data Structures | Stacks | [AND xor OR](https://www.hackerrank.com/challenges/and-xor-or) | Hard | Coming Soon! | +| Data Structures | Stacks | [Waiter](https://www.hackerrank.com/challenges/waiter) | Medium | Coming Soon! | +| Data Structures | Queues | [Queue using Two Stacks](https://www.hackerrank.com/challenges/queue-using-two-stacks) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Queues/Queue%20using%20Two%20Stacks/Solution.java) | +| Data Structures | Queues | [Castle on the Grid](https://www.hackerrank.com/challenges/castle-on-the-grid) | Medium | Coming Soon! | +| Data Structures | Queues | [Down to Zero II](https://www.hackerrank.com/challenges/down-to-zero-ii) | Medium | Coming Soon! | +| Data Structures | Queues | [Truck Tour](https://www.hackerrank.com/challenges/truck-tour) | Hard | Coming Soon! | +| Data Structures | Queues | [Queries with Fixed Length](https://www.hackerrank.com/challenges/queries-with-fixed-length) | Hard | Coming Soon! | +| Data Structures | Heap | [QHEAP1](https://www.hackerrank.com/challenges/qheap1) | Easy | Coming Soon! | +| Data Structures | Heap | [Jesse and Cookies](https://www.hackerrank.com/challenges/jesse-and-cookies) | Easy | Coming Soon! | +| Data Structures | Heap | [Find the Running Median](https://www.hackerrank.com/challenges/find-the-running-median) | Hard | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Heap/Find%20the%20Running%20Median/Solution.java) | +| Data Structures | Heap | [Minimum Average Waiting Time](https://www.hackerrank.com/challenges/minimum-average-waiting-time) | Hard | Coming Soon! | +| Data Structures | Disjoint Set | [Merging Communities](https://www.hackerrank.com/challenges/merging-communities) | Hard | Coming Soon! | +| Data Structures | Disjoint Set | [Components in a graph](https://www.hackerrank.com/challenges/components-in-graph) | Medium | Coming Soon! | +| Data Structures | Disjoint Set | [Kundu and Tree](https://www.hackerrank.com/challenges/kundu-and-tree) | Hard | Coming Soon! | +| Data Structures | Disjoint Set | [Super Maximum Cost Queries](https://www.hackerrank.com/challenges/maximum-cost-queries) | Hard | Coming Soon! | +| Data Structures | Multiple Choice | [Data Structures MCQ 1](https://www.hackerrank.com/challenges/how-well-do-you-know-trees) | Multiple Choice | Coming Soon! | +| Data Structures | Multiple Choice | [Data Structures MCQ 2](https://www.hackerrank.com/challenges/are-you-an-expert-on-data-structures) | Multiple Choice | Coming Soon! | +| Data Structures | Multiple Choice | [Data Structures MCQ 3](https://www.hackerrank.com/challenges/are-you-an-expert-on-data-structures-1) | Multiple Choice | Coming Soon! | +| Data Structures | Trie | [Contacts](https://www.hackerrank.com/challenges/contacts) | Medium | [Solution.java](https://github.com/rshaghoulian/HackerRank-solutions/blob/master/Data%20Structures/Trie/Contacts/Solution.java) | +| Data Structures | Trie | [No Prefix Set](https://www.hackerrank.com/challenges/no-prefix-set) | Hard | Coming Soon! | +| Data Structures | Advanced | [Kindergarten Adventures](https://www.hackerrank.com/challenges/kindergarten-adventures) | Medium | Coming Soon! | +| Data Structures | Advanced | [Cube Summation](https://www.hackerrank.com/challenges/cube-summation) | Hard | Coming Soon! | +| Data Structures | Advanced | [Mr. X and His Shots](https://www.hackerrank.com/challenges/x-and-his-shots) | Medium | Coming Soon! | +| Data Structures | Advanced | [Direct Connections](https://www.hackerrank.com/challenges/direct-connections) | Hard | Coming Soon! | +| Data Structures | Advanced | [Subsequence Weighting](https://www.hackerrank.com/challenges/subsequence-weighting) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Jim and the Skyscrapers](https://www.hackerrank.com/challenges/jim-and-the-skyscrapers) | Medium | Coming Soon! | +| Data Structures | Advanced | [Counting On a Tree](https://www.hackerrank.com/challenges/counting-on-a-tree) | Expert | Coming Soon! | +| Data Structures | Advanced | [Unique Colors](https://www.hackerrank.com/challenges/unique-colors) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Self-Driving Bus](https://www.hackerrank.com/challenges/self-driving-bus) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Fibonacci Numbers Tree](https://www.hackerrank.com/challenges/fibonacci-numbers-tree) | Expert | Coming Soon! | +| Data Structures | Advanced | [Functional Palindromes](https://www.hackerrank.com/challenges/functional-palindromes) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Lazy White Falcon](https://www.hackerrank.com/challenges/lazy-white-falcon) | Hard | Coming Soon! | +| Data Structures | Advanced | [Ticket to Ride](https://www.hackerrank.com/challenges/ticket-to-ride) | Expert | Coming Soon! | +| Data Structures | Advanced | [Heavy Light White Falcon](https://www.hackerrank.com/challenges/heavy-light-white-falcon) | Hard | Coming Soon! | +| Data Structures | Advanced | [Sum of the Maximums](https://www.hackerrank.com/challenges/little-alexey-and-sum-of-maximums) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Heavy Light 2 White Falcon](https://www.hackerrank.com/challenges/heavy-light-2-white-falcon) | Hard | Coming Soon! | +| Data Structures | Advanced | [Library Query](https://www.hackerrank.com/challenges/library-query) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Starfleet](https://www.hackerrank.com/challenges/starfleet) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Almost Equal - Advanced](https://www.hackerrank.com/challenges/almost-equal-advanced) | Expert | Coming Soon! | +| Data Structures | Advanced | [Almost sorted interval](https://www.hackerrank.com/challenges/almost-sorted-interval) | Expert | Coming Soon! | +| Data Structures | Advanced | [Burger Happiness](https://www.hackerrank.com/challenges/burger-happiness) | Hard | Coming Soon! | +| Data Structures | Advanced | [Roy and alpha-beta trees](https://www.hackerrank.com/challenges/roy-and-alpha-beta-trees) | Hard | Coming Soon! | +| Data Structures | Advanced | [Coloring Tree](https://www.hackerrank.com/challenges/coloring-tree) | Hard | Coming Soon! | +| Data Structures | Advanced | [Recalling Early Days GP with Trees](https://www.hackerrank.com/challenges/recalling-early-days-gp-with-trees) | Hard | Coming Soon! | +| Data Structures | Advanced | [Swaps and Sum](https://www.hackerrank.com/challenges/swaps-and-sum) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Arithmetic Progressions](https://www.hackerrank.com/challenges/arithmetic-progressions) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Coolguy and Two Subsequences](https://www.hackerrank.com/challenges/coolguy-and-two-subsequences) | Advanced | Coming Soon! | +| Data Structures | Advanced | [White Falcon And Tree](https://www.hackerrank.com/challenges/white-falcon-and-tree) | Hard | Coming Soon! | +| Data Structures | Advanced | [Subtrees And Paths](https://www.hackerrank.com/challenges/subtrees-and-paths) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Triplets](https://www.hackerrank.com/challenges/triplets) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Beautiful Segments](https://www.hackerrank.com/challenges/beautiful-segments) | Expert | Coming Soon! | +| Data Structures | Advanced | [Divisibility](https://www.hackerrank.com/challenges/ab0) | Expert | Coming Soon! | +| Data Structures | Advanced | [BST maintenance](https://www.hackerrank.com/challenges/bst-maintenance) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Find Maximum Index Product](https://www.hackerrank.com/challenges/find-maximum-index-product) | Medium | Coming Soon! | +| Data Structures | Advanced | [Taxicab Driver's Problem](https://www.hackerrank.com/challenges/taxicab-drivers-problem) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Jaggu Playing with Balloons](https://www.hackerrank.com/challenges/jagia-playing-with-numbers) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Dynamic Summation](https://www.hackerrank.com/challenges/dynamic-summation) | Hard | Coming Soon! | +| Data Structures | Advanced | [Two Array Problem](https://www.hackerrank.com/challenges/weird-queries) | Hard | Coming Soon! | +| Data Structures | Advanced | [Rooted Tree](https://www.hackerrank.com/challenges/rooted-tree) | Hard | Coming Soon! | +| Data Structures | Advanced | [The crazy helix](https://www.hackerrank.com/challenges/helix) | Advanced | Coming Soon! | +| Data Structures | Advanced | [Network administration](https://www.hackerrank.com/challenges/net-admin) | Hard | Coming Soon! | +| Data Structures | Advanced | [Easy Addition](https://www.hackerrank.com/challenges/easy-addition) | Expert | Coming Soon! | +| Data Structures | Advanced | [Find the permutation](https://www.hackerrank.com/challenges/find-the-permutation) | Expert | Coming Soon! | +| Data Structures | Advanced | [Company Retreat](https://www.hackerrank.com/challenges/company-retreat) | Advanced | Coming Soon! |