From 8fd03d5aec9cbb7192e0f3d17274b50fa8db720d Mon Sep 17 00:00:00 2001 From: chirag828049 Date: Wed, 23 Dec 2020 20:15:56 +0530 Subject: [PATCH] Solved issue 238. All Problems organised. Links are fioxed. Readme file updated. --- .../Lonely Integer/solution.cpp | 0 .../Lonely Integer/solution.java | 90 +++++------ .../Lonely Integer/solution.py | 0 .../solution.cpp | 0 .../solution.java | 114 +++++++------- .../solution.py | 0 .../The Coin Change Problem}/solution.cpp | 0 .../The Coin Change Problem}/solution.java | 0 .../The Coin Change Problem}/solution.py | 0 .../{ => Greedy}/Luck Balance/solution.cpp | 0 .../{ => Greedy}/Luck Balance/solution.java | 0 .../{ => Greedy}/Luck Balance/solution.py | 0 .../{ => Greedy}/Marc's Cakewalk/solution.cpp | 0 .../Marc's Cakewalk/solution.java | 0 .../{ => Greedy}/Marc's Cakewalk/solution.py | 0 .../Angry Professor/solution.cpp | 0 .../Angry Professor/solution.java | 0 .../Angry Professor/solution.py | 0 .../Apple and Orange/solution.cpp | 0 .../Apple and Orange/solution.java | 0 .../Apple and Orange/solution.py | 0 .../Bill Division/solution.cpp | 0 .../Bill Division/solution.java | 56 +++---- .../Bill Division/solution.py | 0 .../Breaking the Records/solution.cpp | 0 .../Breaking the Records/solution.java | 142 +++++++++--------- .../Breaking the Records/solution.py | 0 .../Climbing the Leaderboard/solution.cpp | 0 .../Climbing the Leaderboard/solution.java | 88 +++++------ .../Climbing the Leaderboard/solution.py | 0 .../Electronics Shop/solution.cpp | 0 .../Electronics Shop/solution.java | 0 .../Electronics Shop/solution.py | 0 .../Encryption/solution.py | 0 .../Grading Students/Solution.java | 0 .../Grading Students/solution.cpp | 0 .../Grading Students/solution.py | 0 .../Migratory Birds/solution.cpp | 0 .../Migratory Birds/solution.java | 0 .../Migratory Birds/solution.py | 0 .../Number Line Jumps}/solution.cpp | 0 .../Number Line Jumps}/solution.java | 0 .../Number Line Jumps}/solution.py | 0 .../solution.cpp | 0 .../solution.java | 0 .../solution.py | 0 .../Queen's Attack II/solution.cpp | 142 +++++++++--------- .../Queen's Attack II/solution.java | 0 .../Queen's Attack II/solution.py | 0 .../Sales by Match/solution.cpp | 0 .../Sales by Match/solution.java | 132 ++++++++-------- .../Sales by Match/solution.py | 0 .../solution.cpp | 0 .../Save the Prisoner!}/solution.java | 98 ++++++------ .../Save the Prisoner!}/solution.py | 0 .../Sub-array Division/solution.cpp | 0 .../Sub-array Division/solution.java | 80 +++++----- .../Sub-array Division/solution.py | 0 .../{ => Search}/Minimum Loss/solution.cpp | 0 .../{ => Search}/Minimum Loss/solution.java | 0 .../{ => Search}/Minimum Loss/solution.py | 0 .../Birthday Cake Candles/solution.cpp | 0 .../Birthday Cake Candles/solution.java | 100 ++++++------ .../Birthday Cake Candles/solution.py | 0 .../Diagonal Difference/Solution.java | 0 .../Diagonal Difference/solution.cpp | 0 .../Diagonal Difference/solution.py | 0 .../{ => Warmup}/Mini-Max Sum/solution.cpp | 0 .../{ => Warmup}/Mini-Max Sum/solution.java | 82 +++++----- .../{ => Warmup}/Mini-Max Sum/solution.py | 0 README.md | 118 +++++++-------- 71 files changed, 621 insertions(+), 621 deletions(-) rename Algorithms/{ => Bit Manipulation}/Lonely Integer/solution.cpp (100%) rename Algorithms/{ => Bit Manipulation}/Lonely Integer/solution.java (97%) rename Algorithms/{ => Bit Manipulation}/Lonely Integer/solution.py (100%) rename Algorithms/Bit Manipulation/{Xor sequence => Xor-sequence}/solution.cpp (100%) rename Algorithms/Bit Manipulation/{Xor sequence => Xor-sequence}/solution.java (97%) rename Algorithms/Bit Manipulation/{Xor sequence => Xor-sequence}/solution.py (100%) rename Algorithms/{The coin change problem => Dynamic Programming/The Coin Change Problem}/solution.cpp (100%) rename Algorithms/{The coin change problem => Dynamic Programming/The Coin Change Problem}/solution.java (100%) rename Algorithms/{The coin change problem => Dynamic Programming/The Coin Change Problem}/solution.py (100%) rename Algorithms/{ => Greedy}/Luck Balance/solution.cpp (100%) rename Algorithms/{ => Greedy}/Luck Balance/solution.java (100%) rename Algorithms/{ => Greedy}/Luck Balance/solution.py (100%) rename Algorithms/{ => Greedy}/Marc's Cakewalk/solution.cpp (100%) rename Algorithms/{ => Greedy}/Marc's Cakewalk/solution.java (100%) rename Algorithms/{ => Greedy}/Marc's Cakewalk/solution.py (100%) rename Algorithms/{ => Implementation}/Angry Professor/solution.cpp (100%) rename Algorithms/{ => Implementation}/Angry Professor/solution.java (100%) rename Algorithms/{ => Implementation}/Angry Professor/solution.py (100%) rename Algorithms/{ => Implementation}/Apple and Orange/solution.cpp (100%) rename Algorithms/{ => Implementation}/Apple and Orange/solution.java (100%) rename Algorithms/{ => Implementation}/Apple and Orange/solution.py (100%) rename Algorithms/{ => Implementation}/Bill Division/solution.cpp (100%) rename Algorithms/{ => Implementation}/Bill Division/solution.java (96%) rename Algorithms/{ => Implementation}/Bill Division/solution.py (100%) rename Algorithms/{ => Implementation}/Breaking the Records/solution.cpp (100%) rename Algorithms/{ => Implementation}/Breaking the Records/solution.java (97%) rename Algorithms/{ => Implementation}/Breaking the Records/solution.py (100%) rename Algorithms/{ => Implementation}/Climbing the Leaderboard/solution.cpp (100%) rename Algorithms/{ => Implementation}/Climbing the Leaderboard/solution.java (96%) rename Algorithms/{ => Implementation}/Climbing the Leaderboard/solution.py (100%) rename Algorithms/{ => Implementation}/Electronics Shop/solution.cpp (100%) rename Algorithms/{ => Implementation}/Electronics Shop/solution.java (100%) rename Algorithms/{ => Implementation}/Electronics Shop/solution.py (100%) rename Algorithms/{ => Implementation}/Encryption/solution.py (100%) rename Algorithms/{ => Implementation}/Grading Students/Solution.java (100%) rename Algorithms/{ => Implementation}/Grading Students/solution.cpp (100%) rename Algorithms/{ => Implementation}/Grading Students/solution.py (100%) rename Algorithms/{ => Implementation}/Migratory Birds/solution.cpp (100%) rename Algorithms/{ => Implementation}/Migratory Birds/solution.java (100%) rename Algorithms/{ => Implementation}/Migratory Birds/solution.py (100%) rename Algorithms/{Number Line Jump => Implementation/Number Line Jumps}/solution.cpp (100%) rename Algorithms/{Number Line Jump => Implementation/Number Line Jumps}/solution.java (100%) rename Algorithms/{Number Line Jump => Implementation/Number Line Jumps}/solution.py (100%) rename Algorithms/{ => Implementation}/Organizing Containers of Balls/solution.cpp (100%) rename Algorithms/{ => Implementation}/Organizing Containers of Balls/solution.java (100%) rename Algorithms/{ => Implementation}/Organizing Containers of Balls/solution.py (100%) rename Algorithms/{ => Implementation}/Queen's Attack II/solution.cpp (96%) rename Algorithms/{ => Implementation}/Queen's Attack II/solution.java (100%) rename Algorithms/{ => Implementation}/Queen's Attack II/solution.py (100%) rename Algorithms/{ => Implementation}/Sales by Match/solution.cpp (100%) rename Algorithms/{ => Implementation}/Sales by Match/solution.java (97%) rename Algorithms/{ => Implementation}/Sales by Match/solution.py (100%) rename Algorithms/Implementation/{Save The Prisoner => Save the Prisoner!}/solution.cpp (100%) rename Algorithms/{Save The Prisoner => Implementation/Save the Prisoner!}/solution.java (96%) rename Algorithms/{Save The Prisoner => Implementation/Save the Prisoner!}/solution.py (100%) rename Algorithms/{ => Implementation}/Sub-array Division/solution.cpp (100%) rename Algorithms/{ => Implementation}/Sub-array Division/solution.java (96%) rename Algorithms/{ => Implementation}/Sub-array Division/solution.py (100%) rename Algorithms/{ => Search}/Minimum Loss/solution.cpp (100%) rename Algorithms/{ => Search}/Minimum Loss/solution.java (100%) rename Algorithms/{ => Search}/Minimum Loss/solution.py (100%) rename Algorithms/{ => Warmup}/Birthday Cake Candles/solution.cpp (100%) rename Algorithms/{ => Warmup}/Birthday Cake Candles/solution.java (97%) rename Algorithms/{ => Warmup}/Birthday Cake Candles/solution.py (100%) rename Algorithms/{ => Warmup}/Diagonal Difference/Solution.java (100%) rename Algorithms/{ => Warmup}/Diagonal Difference/solution.cpp (100%) rename Algorithms/{ => Warmup}/Diagonal Difference/solution.py (100%) rename Algorithms/{ => Warmup}/Mini-Max Sum/solution.cpp (100%) rename Algorithms/{ => Warmup}/Mini-Max Sum/solution.java (96%) rename Algorithms/{ => Warmup}/Mini-Max Sum/solution.py (100%) diff --git a/Algorithms/Lonely Integer/solution.cpp b/Algorithms/Bit Manipulation/Lonely Integer/solution.cpp similarity index 100% rename from Algorithms/Lonely Integer/solution.cpp rename to Algorithms/Bit Manipulation/Lonely Integer/solution.cpp diff --git a/Algorithms/Lonely Integer/solution.java b/Algorithms/Bit Manipulation/Lonely Integer/solution.java similarity index 97% rename from Algorithms/Lonely Integer/solution.java rename to Algorithms/Bit Manipulation/Lonely Integer/solution.java index f10fa697..484285b3 100644 --- a/Algorithms/Lonely Integer/solution.java +++ b/Algorithms/Bit Manipulation/Lonely Integer/solution.java @@ -1,45 +1,45 @@ -import java.io.*; -import java.math.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.regex.*; - -public class Solution { - - // The method would return the unique value in the array - // O(n) runtime. O(1) space. Uses XOR. Keep in mind: - // 1) x ^ x = 0 - // 2) x ^ 0 = x - // 3) XOR is commutative and associative - static int lonelyinteger(int[] a) { - // We would XOR all the numbers in the array - // Only the unique number would be left - int val = 0; - for (int num : a) { - val = val ^ num; // ^ is XOR operator - } - return val; - } - - /* Driver Code */ - private static final Scanner scanner = new Scanner(System.in); - public static void main(String[] args) throws IOException { - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); - int n = scanner.nextInt(); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - int[] a = new int[n]; - String[] aItems = scanner.nextLine().split(" "); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - for (int i = 0; i < n; i++) { - int aItem = Integer.parseInt(aItems[i]); - a[i] = aItem; - } - int result = lonelyinteger(a); - bufferedWriter.write(String.valueOf(result)); - bufferedWriter.newLine(); - bufferedWriter.close(); - scanner.close(); - } -} +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + // The method would return the unique value in the array + // O(n) runtime. O(1) space. Uses XOR. Keep in mind: + // 1) x ^ x = 0 + // 2) x ^ 0 = x + // 3) XOR is commutative and associative + static int lonelyinteger(int[] a) { + // We would XOR all the numbers in the array + // Only the unique number would be left + int val = 0; + for (int num : a) { + val = val ^ num; // ^ is XOR operator + } + return val; + } + + /* Driver Code */ + private static final Scanner scanner = new Scanner(System.in); + public static void main(String[] args) throws IOException { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); + int n = scanner.nextInt(); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + int[] a = new int[n]; + String[] aItems = scanner.nextLine().split(" "); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + for (int i = 0; i < n; i++) { + int aItem = Integer.parseInt(aItems[i]); + a[i] = aItem; + } + int result = lonelyinteger(a); + bufferedWriter.write(String.valueOf(result)); + bufferedWriter.newLine(); + bufferedWriter.close(); + scanner.close(); + } +} diff --git a/Algorithms/Lonely Integer/solution.py b/Algorithms/Bit Manipulation/Lonely Integer/solution.py similarity index 100% rename from Algorithms/Lonely Integer/solution.py rename to Algorithms/Bit Manipulation/Lonely Integer/solution.py diff --git a/Algorithms/Bit Manipulation/Xor sequence/solution.cpp b/Algorithms/Bit Manipulation/Xor-sequence/solution.cpp similarity index 100% rename from Algorithms/Bit Manipulation/Xor sequence/solution.cpp rename to Algorithms/Bit Manipulation/Xor-sequence/solution.cpp diff --git a/Algorithms/Bit Manipulation/Xor sequence/solution.java b/Algorithms/Bit Manipulation/Xor-sequence/solution.java similarity index 97% rename from Algorithms/Bit Manipulation/Xor sequence/solution.java rename to Algorithms/Bit Manipulation/Xor-sequence/solution.java index 5bdb8505..3508a2a6 100644 --- a/Algorithms/Bit Manipulation/Xor sequence/solution.java +++ b/Algorithms/Bit Manipulation/Xor-sequence/solution.java @@ -1,57 +1,57 @@ -import java.io.*; -import java.math.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.regex.*; - -public class Solution { - - // Method to compute the value of XOR sequence - static long xorSequence(long l, long r) { - //The answer is the xor of value obtained by calc function of left and right range - long answer = calc(r) ^ calc(l - 1); - return answer; - } - //Perform xor of 7 with the limit passed and return on the basis of the conditions - private static long calc(long limit) { - switch ((int) (limit & 7)) { - case 0: - return limit; - case 1: - return limit; - case 2: - return 2; - case 3: - return 2; - case 4: - return limit + 2; - case 5: - return limit + 2; - case 6: - return 0; - case 7: - return 0; - default: - throw new RuntimeException(); - } - } - /* Driver Code */ - private static final Scanner scanner = new Scanner(System.in); - public static void main(String[] args) throws IOException { - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); - int q = scanner.nextInt(); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - for (int qItr = 0; qItr < q; qItr++) { - String[] lr = scanner.nextLine().split(" "); - long l = Long.parseLong(lr[0]); - long r = Long.parseLong(lr[1]); - long result = xorSequence(l, r); - bufferedWriter.write(String.valueOf(result)); - bufferedWriter.newLine(); - } - bufferedWriter.close(); - scanner.close(); - } -} +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + // Method to compute the value of XOR sequence + static long xorSequence(long l, long r) { + //The answer is the xor of value obtained by calc function of left and right range + long answer = calc(r) ^ calc(l - 1); + return answer; + } + //Perform xor of 7 with the limit passed and return on the basis of the conditions + private static long calc(long limit) { + switch ((int) (limit & 7)) { + case 0: + return limit; + case 1: + return limit; + case 2: + return 2; + case 3: + return 2; + case 4: + return limit + 2; + case 5: + return limit + 2; + case 6: + return 0; + case 7: + return 0; + default: + throw new RuntimeException(); + } + } + /* Driver Code */ + private static final Scanner scanner = new Scanner(System.in); + public static void main(String[] args) throws IOException { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); + int q = scanner.nextInt(); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + for (int qItr = 0; qItr < q; qItr++) { + String[] lr = scanner.nextLine().split(" "); + long l = Long.parseLong(lr[0]); + long r = Long.parseLong(lr[1]); + long result = xorSequence(l, r); + bufferedWriter.write(String.valueOf(result)); + bufferedWriter.newLine(); + } + bufferedWriter.close(); + scanner.close(); + } +} diff --git a/Algorithms/Bit Manipulation/Xor sequence/solution.py b/Algorithms/Bit Manipulation/Xor-sequence/solution.py similarity index 100% rename from Algorithms/Bit Manipulation/Xor sequence/solution.py rename to Algorithms/Bit Manipulation/Xor-sequence/solution.py diff --git a/Algorithms/The coin change problem/solution.cpp b/Algorithms/Dynamic Programming/The Coin Change Problem/solution.cpp similarity index 100% rename from Algorithms/The coin change problem/solution.cpp rename to Algorithms/Dynamic Programming/The Coin Change Problem/solution.cpp diff --git a/Algorithms/The coin change problem/solution.java b/Algorithms/Dynamic Programming/The Coin Change Problem/solution.java similarity index 100% rename from Algorithms/The coin change problem/solution.java rename to Algorithms/Dynamic Programming/The Coin Change Problem/solution.java diff --git a/Algorithms/The coin change problem/solution.py b/Algorithms/Dynamic Programming/The Coin Change Problem/solution.py similarity index 100% rename from Algorithms/The coin change problem/solution.py rename to Algorithms/Dynamic Programming/The Coin Change Problem/solution.py diff --git a/Algorithms/Luck Balance/solution.cpp b/Algorithms/Greedy/Luck Balance/solution.cpp similarity index 100% rename from Algorithms/Luck Balance/solution.cpp rename to Algorithms/Greedy/Luck Balance/solution.cpp diff --git a/Algorithms/Luck Balance/solution.java b/Algorithms/Greedy/Luck Balance/solution.java similarity index 100% rename from Algorithms/Luck Balance/solution.java rename to Algorithms/Greedy/Luck Balance/solution.java diff --git a/Algorithms/Luck Balance/solution.py b/Algorithms/Greedy/Luck Balance/solution.py similarity index 100% rename from Algorithms/Luck Balance/solution.py rename to Algorithms/Greedy/Luck Balance/solution.py diff --git a/Algorithms/Marc's Cakewalk/solution.cpp b/Algorithms/Greedy/Marc's Cakewalk/solution.cpp similarity index 100% rename from Algorithms/Marc's Cakewalk/solution.cpp rename to Algorithms/Greedy/Marc's Cakewalk/solution.cpp diff --git a/Algorithms/Marc's Cakewalk/solution.java b/Algorithms/Greedy/Marc's Cakewalk/solution.java similarity index 100% rename from Algorithms/Marc's Cakewalk/solution.java rename to Algorithms/Greedy/Marc's Cakewalk/solution.java diff --git a/Algorithms/Marc's Cakewalk/solution.py b/Algorithms/Greedy/Marc's Cakewalk/solution.py similarity index 100% rename from Algorithms/Marc's Cakewalk/solution.py rename to Algorithms/Greedy/Marc's Cakewalk/solution.py diff --git a/Algorithms/Angry Professor/solution.cpp b/Algorithms/Implementation/Angry Professor/solution.cpp similarity index 100% rename from Algorithms/Angry Professor/solution.cpp rename to Algorithms/Implementation/Angry Professor/solution.cpp diff --git a/Algorithms/Angry Professor/solution.java b/Algorithms/Implementation/Angry Professor/solution.java similarity index 100% rename from Algorithms/Angry Professor/solution.java rename to Algorithms/Implementation/Angry Professor/solution.java diff --git a/Algorithms/Angry Professor/solution.py b/Algorithms/Implementation/Angry Professor/solution.py similarity index 100% rename from Algorithms/Angry Professor/solution.py rename to Algorithms/Implementation/Angry Professor/solution.py diff --git a/Algorithms/Apple and Orange/solution.cpp b/Algorithms/Implementation/Apple and Orange/solution.cpp similarity index 100% rename from Algorithms/Apple and Orange/solution.cpp rename to Algorithms/Implementation/Apple and Orange/solution.cpp diff --git a/Algorithms/Apple and Orange/solution.java b/Algorithms/Implementation/Apple and Orange/solution.java similarity index 100% rename from Algorithms/Apple and Orange/solution.java rename to Algorithms/Implementation/Apple and Orange/solution.java diff --git a/Algorithms/Apple and Orange/solution.py b/Algorithms/Implementation/Apple and Orange/solution.py similarity index 100% rename from Algorithms/Apple and Orange/solution.py rename to Algorithms/Implementation/Apple and Orange/solution.py diff --git a/Algorithms/Bill Division/solution.cpp b/Algorithms/Implementation/Bill Division/solution.cpp similarity index 100% rename from Algorithms/Bill Division/solution.cpp rename to Algorithms/Implementation/Bill Division/solution.cpp diff --git a/Algorithms/Bill Division/solution.java b/Algorithms/Implementation/Bill Division/solution.java similarity index 96% rename from Algorithms/Bill Division/solution.java rename to Algorithms/Implementation/Bill Division/solution.java index efbb3bd2..e21c7fd5 100644 --- a/Algorithms/Bill Division/solution.java +++ b/Algorithms/Implementation/Bill Division/solution.java @@ -1,29 +1,29 @@ -import java.util.*; - -class Solution { - - public static void bonAppetit(int[] cost, int k, int charged) { - int total = (charged << 1); - // Traverse through the cost array and subtract the current value from cost array - for (int i : cost) { - total = total - i; - } - // If total is greater than print half the cost - // else print Bon Appetit - System.out.println( (total >= 0) ? cost[k] / 2 : "Bon Appetit"); - } - - public static void main(String[] args) { - Scanner scan = new Scanner(System.in); - int n = scan.nextInt(); - int k = scan.nextInt(); - int[] cost = new int[n]; - for (int i = 0; i < n; i++) { - cost[i] = scan.nextInt(); - } - int charged = scan.nextInt(); - scan.close(); - - bonAppetit(cost, k, charged); - } +import java.util.*; + +class Solution { + + public static void bonAppetit(int[] cost, int k, int charged) { + int total = (charged << 1); + // Traverse through the cost array and subtract the current value from cost array + for (int i : cost) { + total = total - i; + } + // If total is greater than print half the cost + // else print Bon Appetit + System.out.println( (total >= 0) ? cost[k] / 2 : "Bon Appetit"); + } + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + int k = scan.nextInt(); + int[] cost = new int[n]; + for (int i = 0; i < n; i++) { + cost[i] = scan.nextInt(); + } + int charged = scan.nextInt(); + scan.close(); + + bonAppetit(cost, k, charged); + } } \ No newline at end of file diff --git a/Algorithms/Bill Division/solution.py b/Algorithms/Implementation/Bill Division/solution.py similarity index 100% rename from Algorithms/Bill Division/solution.py rename to Algorithms/Implementation/Bill Division/solution.py diff --git a/Algorithms/Breaking the Records/solution.cpp b/Algorithms/Implementation/Breaking the Records/solution.cpp similarity index 100% rename from Algorithms/Breaking the Records/solution.cpp rename to Algorithms/Implementation/Breaking the Records/solution.cpp diff --git a/Algorithms/Breaking the Records/solution.java b/Algorithms/Implementation/Breaking the Records/solution.java similarity index 97% rename from Algorithms/Breaking the Records/solution.java rename to Algorithms/Implementation/Breaking the Records/solution.java index c2408f53..f5a9db8d 100644 --- a/Algorithms/Breaking the Records/solution.java +++ b/Algorithms/Implementation/Breaking the Records/solution.java @@ -1,71 +1,71 @@ -import java.io.*; -import java.math.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.regex.*; - -public class Solution { - - //This method will compute the number of times - //BestScore was broke and WorstScore was broke - static int[] breakingRecords(int[] scores) { - //Set bestScore and worstScore to first value of scores array - int bestScore = scores[0], worstScore = scores[0]; - //Set count of bestScoreinc and worstscoredec to zero - int countBestScoreInc = 0, countWorstScoreDec = 0; - //Traverse throught the remaining array - for(int i = 1; i < scores.length; i ++) { - //if bestScore is broken - //Update bestScore and increase count by 1 - if(scores[i] > bestScore) { - bestScore = scores[i]; - countBestScoreInc ++; - } - //if worstScore is broken - //Update worstScore and decrease count by 1 - if(scores[i] < worstScore) { - worstScore = scores[i]; - countWorstScoreDec ++; - } - } - //Finally return the count of bestScoreInc and worstScoreDec - return new int[]{countBestScoreInc, countWorstScoreDec}; - } - - private static final Scanner scanner = new Scanner(System.in); - - public static void main(String[] args) throws IOException { - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); - - int n = scanner.nextInt(); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - - int[] scores = new int[n]; - - String[] scoresItems = scanner.nextLine().split(" "); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - - for (int i = 0; i < n; i++) { - int scoresItem = Integer.parseInt(scoresItems[i]); - scores[i] = scoresItem; - } - - int[] result = breakingRecords(scores); - - for (int i = 0; i < result.length; i++) { - bufferedWriter.write(String.valueOf(result[i])); - - if (i != result.length - 1) { - bufferedWriter.write(" "); - } - } - - bufferedWriter.newLine(); - - bufferedWriter.close(); - - scanner.close(); - } -} +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + //This method will compute the number of times + //BestScore was broke and WorstScore was broke + static int[] breakingRecords(int[] scores) { + //Set bestScore and worstScore to first value of scores array + int bestScore = scores[0], worstScore = scores[0]; + //Set count of bestScoreinc and worstscoredec to zero + int countBestScoreInc = 0, countWorstScoreDec = 0; + //Traverse throught the remaining array + for(int i = 1; i < scores.length; i ++) { + //if bestScore is broken + //Update bestScore and increase count by 1 + if(scores[i] > bestScore) { + bestScore = scores[i]; + countBestScoreInc ++; + } + //if worstScore is broken + //Update worstScore and decrease count by 1 + if(scores[i] < worstScore) { + worstScore = scores[i]; + countWorstScoreDec ++; + } + } + //Finally return the count of bestScoreInc and worstScoreDec + return new int[]{countBestScoreInc, countWorstScoreDec}; + } + + private static final Scanner scanner = new Scanner(System.in); + + public static void main(String[] args) throws IOException { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); + + int n = scanner.nextInt(); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + + int[] scores = new int[n]; + + String[] scoresItems = scanner.nextLine().split(" "); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + + for (int i = 0; i < n; i++) { + int scoresItem = Integer.parseInt(scoresItems[i]); + scores[i] = scoresItem; + } + + int[] result = breakingRecords(scores); + + for (int i = 0; i < result.length; i++) { + bufferedWriter.write(String.valueOf(result[i])); + + if (i != result.length - 1) { + bufferedWriter.write(" "); + } + } + + bufferedWriter.newLine(); + + bufferedWriter.close(); + + scanner.close(); + } +} diff --git a/Algorithms/Breaking the Records/solution.py b/Algorithms/Implementation/Breaking the Records/solution.py similarity index 100% rename from Algorithms/Breaking the Records/solution.py rename to Algorithms/Implementation/Breaking the Records/solution.py diff --git a/Algorithms/Climbing the Leaderboard/solution.cpp b/Algorithms/Implementation/Climbing the Leaderboard/solution.cpp similarity index 100% rename from Algorithms/Climbing the Leaderboard/solution.cpp rename to Algorithms/Implementation/Climbing the Leaderboard/solution.cpp diff --git a/Algorithms/Climbing the Leaderboard/solution.java b/Algorithms/Implementation/Climbing the Leaderboard/solution.java similarity index 96% rename from Algorithms/Climbing the Leaderboard/solution.java rename to Algorithms/Implementation/Climbing the Leaderboard/solution.java index c5a7c62b..3205d32b 100644 --- a/Algorithms/Climbing the Leaderboard/solution.java +++ b/Algorithms/Implementation/Climbing the Leaderboard/solution.java @@ -1,45 +1,45 @@ -import java.util.Scanner; - -// Time Complexity: O(n + m) -// Space Complexity: O(1) (other than storing input) -public class Solution { - public static void main(String[] args) { - /* Save input - discard duplicates in leaderboard */ - Scanner scan = new Scanner(System.in); - int n = scan.nextInt(); - int lastScore = -1; - int[] scores = new int[n]; - int index = 0; - - while (n-- > 0) { - int currScore = scan.nextInt(); - if (currScore != lastScore) { - scores[index] = currScore; - index++; - } - lastScore = currScore; - } - - int m = scan.nextInt(); - int[] alice = new int[m]; - for (int i = 0; i < m; i++) { - alice[i] = scan.nextInt(); - } - scan.close(); - - /* Print ranks */ - int i = index - 1; - for (int aliceScore : alice) { - while (i >= 0) { - if (aliceScore < scores[i]) { - System.out.println(i + 2); // add 2 to get correct rank - break; - } - i--; - } - if (i < 0) { // if true, each remaining aliceScore is highest score - System.out.println(1); - } - } - } +import java.util.Scanner; + +// Time Complexity: O(n + m) +// Space Complexity: O(1) (other than storing input) +public class Solution { + public static void main(String[] args) { + /* Save input - discard duplicates in leaderboard */ + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + int lastScore = -1; + int[] scores = new int[n]; + int index = 0; + + while (n-- > 0) { + int currScore = scan.nextInt(); + if (currScore != lastScore) { + scores[index] = currScore; + index++; + } + lastScore = currScore; + } + + int m = scan.nextInt(); + int[] alice = new int[m]; + for (int i = 0; i < m; i++) { + alice[i] = scan.nextInt(); + } + scan.close(); + + /* Print ranks */ + int i = index - 1; + for (int aliceScore : alice) { + while (i >= 0) { + if (aliceScore < scores[i]) { + System.out.println(i + 2); // add 2 to get correct rank + break; + } + i--; + } + if (i < 0) { // if true, each remaining aliceScore is highest score + System.out.println(1); + } + } + } } \ No newline at end of file diff --git a/Algorithms/Climbing the Leaderboard/solution.py b/Algorithms/Implementation/Climbing the Leaderboard/solution.py similarity index 100% rename from Algorithms/Climbing the Leaderboard/solution.py rename to Algorithms/Implementation/Climbing the Leaderboard/solution.py diff --git a/Algorithms/Electronics Shop/solution.cpp b/Algorithms/Implementation/Electronics Shop/solution.cpp similarity index 100% rename from Algorithms/Electronics Shop/solution.cpp rename to Algorithms/Implementation/Electronics Shop/solution.cpp diff --git a/Algorithms/Electronics Shop/solution.java b/Algorithms/Implementation/Electronics Shop/solution.java similarity index 100% rename from Algorithms/Electronics Shop/solution.java rename to Algorithms/Implementation/Electronics Shop/solution.java diff --git a/Algorithms/Electronics Shop/solution.py b/Algorithms/Implementation/Electronics Shop/solution.py similarity index 100% rename from Algorithms/Electronics Shop/solution.py rename to Algorithms/Implementation/Electronics Shop/solution.py diff --git a/Algorithms/Encryption/solution.py b/Algorithms/Implementation/Encryption/solution.py similarity index 100% rename from Algorithms/Encryption/solution.py rename to Algorithms/Implementation/Encryption/solution.py diff --git a/Algorithms/Grading Students/Solution.java b/Algorithms/Implementation/Grading Students/Solution.java similarity index 100% rename from Algorithms/Grading Students/Solution.java rename to Algorithms/Implementation/Grading Students/Solution.java diff --git a/Algorithms/Grading Students/solution.cpp b/Algorithms/Implementation/Grading Students/solution.cpp similarity index 100% rename from Algorithms/Grading Students/solution.cpp rename to Algorithms/Implementation/Grading Students/solution.cpp diff --git a/Algorithms/Grading Students/solution.py b/Algorithms/Implementation/Grading Students/solution.py similarity index 100% rename from Algorithms/Grading Students/solution.py rename to Algorithms/Implementation/Grading Students/solution.py diff --git a/Algorithms/Migratory Birds/solution.cpp b/Algorithms/Implementation/Migratory Birds/solution.cpp similarity index 100% rename from Algorithms/Migratory Birds/solution.cpp rename to Algorithms/Implementation/Migratory Birds/solution.cpp diff --git a/Algorithms/Migratory Birds/solution.java b/Algorithms/Implementation/Migratory Birds/solution.java similarity index 100% rename from Algorithms/Migratory Birds/solution.java rename to Algorithms/Implementation/Migratory Birds/solution.java diff --git a/Algorithms/Migratory Birds/solution.py b/Algorithms/Implementation/Migratory Birds/solution.py similarity index 100% rename from Algorithms/Migratory Birds/solution.py rename to Algorithms/Implementation/Migratory Birds/solution.py diff --git a/Algorithms/Number Line Jump/solution.cpp b/Algorithms/Implementation/Number Line Jumps/solution.cpp similarity index 100% rename from Algorithms/Number Line Jump/solution.cpp rename to Algorithms/Implementation/Number Line Jumps/solution.cpp diff --git a/Algorithms/Number Line Jump/solution.java b/Algorithms/Implementation/Number Line Jumps/solution.java similarity index 100% rename from Algorithms/Number Line Jump/solution.java rename to Algorithms/Implementation/Number Line Jumps/solution.java diff --git a/Algorithms/Number Line Jump/solution.py b/Algorithms/Implementation/Number Line Jumps/solution.py similarity index 100% rename from Algorithms/Number Line Jump/solution.py rename to Algorithms/Implementation/Number Line Jumps/solution.py diff --git a/Algorithms/Organizing Containers of Balls/solution.cpp b/Algorithms/Implementation/Organizing Containers of Balls/solution.cpp similarity index 100% rename from Algorithms/Organizing Containers of Balls/solution.cpp rename to Algorithms/Implementation/Organizing Containers of Balls/solution.cpp diff --git a/Algorithms/Organizing Containers of Balls/solution.java b/Algorithms/Implementation/Organizing Containers of Balls/solution.java similarity index 100% rename from Algorithms/Organizing Containers of Balls/solution.java rename to Algorithms/Implementation/Organizing Containers of Balls/solution.java diff --git a/Algorithms/Organizing Containers of Balls/solution.py b/Algorithms/Implementation/Organizing Containers of Balls/solution.py similarity index 100% rename from Algorithms/Organizing Containers of Balls/solution.py rename to Algorithms/Implementation/Organizing Containers of Balls/solution.py diff --git a/Algorithms/Queen's Attack II/solution.cpp b/Algorithms/Implementation/Queen's Attack II/solution.cpp similarity index 96% rename from Algorithms/Queen's Attack II/solution.cpp rename to Algorithms/Implementation/Queen's Attack II/solution.cpp index a49b0a6c..31786056 100644 --- a/Algorithms/Queen's Attack II/solution.cpp +++ b/Algorithms/Implementation/Queen's Attack II/solution.cpp @@ -1,71 +1,71 @@ -/* The key idea for this approach is that you can iterate over the obstacles and for those that are in the queen's path, -calculate the free cells up to that obstacle. -If there is no obstacle in the path you have to calculate the number of free cells up to the edge of the board in that direction. */ - - -#include -#include -#include -#include - -using namespace std; - -map ,int> mp; - -int ans,n,x,y,x1,y1,k; - -const int maxi=1e5; - -//(x,y) is the current position. - -int range(int x,int y) -{ - return(x<=n && x>0 && y<=n && y>0); -} - - -void check(int x,int y,int xx, int yy) //Check function, will check the condition and modify the current position. -{ - while(range(x,y) && !mp[{x,y}]) - { - x+=xx; - y+=yy; - ans++; - } -} -// Main function -int main() -{ - scanf("%d%d",&n,&k); - - assert(0>x>>y; - assert(x>0 && x<=n); - assert(y>0 && y<=n); - - - while(k--) - { - scanf("%d%d",&x1,&y1); - - assert(x1!=x || y1!=y); - assert(x1>0 && x1<=n); - assert(y1>0 && y1<=n); - - mp[{x1,y1}]=1; - } - - check(x+1,y,1,0); //Check and one step horizontal move to the right. - check(x-1,y,-1,0); //Check and one step horizontal move to the left. - check(x,y+1,0,1); //Check and one step diagonal move up. - check(x,y-1,0,-1); //Check and one step diagonal move down. - check(x+1,y+1,1,1); //check and one step diagonal move up-right. - check(x+1,y-1,1,-1); // check and one step diagonal move right-down. - check(x-1,y+1,-1,1); //Check and one step diagonal move left-up. - check(x-1,y-1,-1,-1); // check and one step diagonal move down-left. - - printf("%d\n",ans); // Print the output - return 0; -} +/* The key idea for this approach is that you can iterate over the obstacles and for those that are in the queen's path, +calculate the free cells up to that obstacle. +If there is no obstacle in the path you have to calculate the number of free cells up to the edge of the board in that direction. */ + + +#include +#include +#include +#include + +using namespace std; + +map ,int> mp; + +int ans,n,x,y,x1,y1,k; + +const int maxi=1e5; + +//(x,y) is the current position. + +int range(int x,int y) +{ + return(x<=n && x>0 && y<=n && y>0); +} + + +void check(int x,int y,int xx, int yy) //Check function, will check the condition and modify the current position. +{ + while(range(x,y) && !mp[{x,y}]) + { + x+=xx; + y+=yy; + ans++; + } +} +// Main function +int main() +{ + scanf("%d%d",&n,&k); + + assert(0>x>>y; + assert(x>0 && x<=n); + assert(y>0 && y<=n); + + + while(k--) + { + scanf("%d%d",&x1,&y1); + + assert(x1!=x || y1!=y); + assert(x1>0 && x1<=n); + assert(y1>0 && y1<=n); + + mp[{x1,y1}]=1; + } + + check(x+1,y,1,0); //Check and one step horizontal move to the right. + check(x-1,y,-1,0); //Check and one step horizontal move to the left. + check(x,y+1,0,1); //Check and one step diagonal move up. + check(x,y-1,0,-1); //Check and one step diagonal move down. + check(x+1,y+1,1,1); //check and one step diagonal move up-right. + check(x+1,y-1,1,-1); // check and one step diagonal move right-down. + check(x-1,y+1,-1,1); //Check and one step diagonal move left-up. + check(x-1,y-1,-1,-1); // check and one step diagonal move down-left. + + printf("%d\n",ans); // Print the output + return 0; +} diff --git a/Algorithms/Queen's Attack II/solution.java b/Algorithms/Implementation/Queen's Attack II/solution.java similarity index 100% rename from Algorithms/Queen's Attack II/solution.java rename to Algorithms/Implementation/Queen's Attack II/solution.java diff --git a/Algorithms/Queen's Attack II/solution.py b/Algorithms/Implementation/Queen's Attack II/solution.py similarity index 100% rename from Algorithms/Queen's Attack II/solution.py rename to Algorithms/Implementation/Queen's Attack II/solution.py diff --git a/Algorithms/Sales by Match/solution.cpp b/Algorithms/Implementation/Sales by Match/solution.cpp similarity index 100% rename from Algorithms/Sales by Match/solution.cpp rename to Algorithms/Implementation/Sales by Match/solution.cpp diff --git a/Algorithms/Sales by Match/solution.java b/Algorithms/Implementation/Sales by Match/solution.java similarity index 97% rename from Algorithms/Sales by Match/solution.java rename to Algorithms/Implementation/Sales by Match/solution.java index 23c45ad4..877d0556 100644 --- a/Algorithms/Sales by Match/solution.java +++ b/Algorithms/Implementation/Sales by Match/solution.java @@ -1,66 +1,66 @@ -import java.io.*; -import java.math.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.regex.*; - -public class Solution { - - // This method would return the count of pairs of socks - static int sockMerchant(int n, int[] arr) { - int countPairs = 0; - //In this approach we would keep record of each sock by maintaining - //a hash map that will store the sock number and its count in the array - HashMap hMap = new HashMap<>(); - //We would traverse through the sock array and update our hashMap - for(int i = 0; i < arr.length; i ++) { - if(hMap.containsKey(arr[i])) { - hMap.put(arr[i], hMap.get(arr[i]) + 1); - } - else { - hMap.put(arr[i], 1); - } - } - //We will traverse through the hashmap and if count of - //any sock number is greater than 1 we will increment the count - for(Map.Entry x : hMap.entrySet()) { - System.out.println(x.getKey() + " " + x.getValue()); - if(x.getValue() >= 2) - { - countPairs += x.getValue() / 2; - } - } - //Finally we return the count of Pairs of Socks - return countPairs; - } - - private static final Scanner scanner = new Scanner(System.in); - - public static void main(String[] args) throws IOException { - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); - - int n = scanner.nextInt(); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - - int[] ar = new int[n]; - - String[] arItems = scanner.nextLine().split(" "); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - - for (int i = 0; i < n; i++) { - int arItem = Integer.parseInt(arItems[i]); - ar[i] = arItem; - } - - int result = sockMerchant(n, ar); - - bufferedWriter.write(String.valueOf(result)); - bufferedWriter.newLine(); - - bufferedWriter.close(); - - scanner.close(); - } -} +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + // This method would return the count of pairs of socks + static int sockMerchant(int n, int[] arr) { + int countPairs = 0; + //In this approach we would keep record of each sock by maintaining + //a hash map that will store the sock number and its count in the array + HashMap hMap = new HashMap<>(); + //We would traverse through the sock array and update our hashMap + for(int i = 0; i < arr.length; i ++) { + if(hMap.containsKey(arr[i])) { + hMap.put(arr[i], hMap.get(arr[i]) + 1); + } + else { + hMap.put(arr[i], 1); + } + } + //We will traverse through the hashmap and if count of + //any sock number is greater than 1 we will increment the count + for(Map.Entry x : hMap.entrySet()) { + System.out.println(x.getKey() + " " + x.getValue()); + if(x.getValue() >= 2) + { + countPairs += x.getValue() / 2; + } + } + //Finally we return the count of Pairs of Socks + return countPairs; + } + + private static final Scanner scanner = new Scanner(System.in); + + public static void main(String[] args) throws IOException { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); + + int n = scanner.nextInt(); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + + int[] ar = new int[n]; + + String[] arItems = scanner.nextLine().split(" "); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + + for (int i = 0; i < n; i++) { + int arItem = Integer.parseInt(arItems[i]); + ar[i] = arItem; + } + + int result = sockMerchant(n, ar); + + bufferedWriter.write(String.valueOf(result)); + bufferedWriter.newLine(); + + bufferedWriter.close(); + + scanner.close(); + } +} diff --git a/Algorithms/Sales by Match/solution.py b/Algorithms/Implementation/Sales by Match/solution.py similarity index 100% rename from Algorithms/Sales by Match/solution.py rename to Algorithms/Implementation/Sales by Match/solution.py diff --git a/Algorithms/Implementation/Save The Prisoner/solution.cpp b/Algorithms/Implementation/Save the Prisoner!/solution.cpp similarity index 100% rename from Algorithms/Implementation/Save The Prisoner/solution.cpp rename to Algorithms/Implementation/Save the Prisoner!/solution.cpp diff --git a/Algorithms/Save The Prisoner/solution.java b/Algorithms/Implementation/Save the Prisoner!/solution.java similarity index 96% rename from Algorithms/Save The Prisoner/solution.java rename to Algorithms/Implementation/Save the Prisoner!/solution.java index 53eb46d9..30a6bb94 100644 --- a/Algorithms/Save The Prisoner/solution.java +++ b/Algorithms/Implementation/Save the Prisoner!/solution.java @@ -1,50 +1,50 @@ -import java.io.*; -import java.math.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.regex.*; - -public class Solution { - - - // The index of last prisoner who gets the last piece of candy is m + s - 1 . - // But if this index becomes larger than the number of prisoners , then we have to start traversing from the beginning (since we are moving in a circle), hence it is required to find modulus of this sum. - // Increment by 1 , since starting index is 1. - - //Method to find the index. - static int saveThePrisoner(int n, int m, int s) { - int index = (m + s - 2)% n +1 ; - return index; - - } - - private static final Scanner scanner = new Scanner(System.in); - - public static void main(String[] args) throws IOException { - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); - - int t = scanner.nextInt(); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - - for (int tItr = 0; tItr < t; tItr++) { - String[] nms = scanner.nextLine().split(" "); - - int n = Integer.parseInt(nms[0]); - - int m = Integer.parseInt(nms[1]); - - int s = Integer.parseInt(nms[2]); - - int result = saveThePrisoner(n, m, s); - - bufferedWriter.write(String.valueOf(result)); - bufferedWriter.newLine(); - } - - bufferedWriter.close(); - - scanner.close(); - } +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + + // The index of last prisoner who gets the last piece of candy is m + s - 1 . + // But if this index becomes larger than the number of prisoners , then we have to start traversing from the beginning (since we are moving in a circle), hence it is required to find modulus of this sum. + // Increment by 1 , since starting index is 1. + + //Method to find the index. + static int saveThePrisoner(int n, int m, int s) { + int index = (m + s - 2)% n +1 ; + return index; + + } + + private static final Scanner scanner = new Scanner(System.in); + + public static void main(String[] args) throws IOException { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); + + int t = scanner.nextInt(); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + + for (int tItr = 0; tItr < t; tItr++) { + String[] nms = scanner.nextLine().split(" "); + + int n = Integer.parseInt(nms[0]); + + int m = Integer.parseInt(nms[1]); + + int s = Integer.parseInt(nms[2]); + + int result = saveThePrisoner(n, m, s); + + bufferedWriter.write(String.valueOf(result)); + bufferedWriter.newLine(); + } + + bufferedWriter.close(); + + scanner.close(); + } } \ No newline at end of file diff --git a/Algorithms/Save The Prisoner/solution.py b/Algorithms/Implementation/Save the Prisoner!/solution.py similarity index 100% rename from Algorithms/Save The Prisoner/solution.py rename to Algorithms/Implementation/Save the Prisoner!/solution.py diff --git a/Algorithms/Sub-array Division/solution.cpp b/Algorithms/Implementation/Sub-array Division/solution.cpp similarity index 100% rename from Algorithms/Sub-array Division/solution.cpp rename to Algorithms/Implementation/Sub-array Division/solution.cpp diff --git a/Algorithms/Sub-array Division/solution.java b/Algorithms/Implementation/Sub-array Division/solution.java similarity index 96% rename from Algorithms/Sub-array Division/solution.java rename to Algorithms/Implementation/Sub-array Division/solution.java index db8f65b5..1190f19e 100644 --- a/Algorithms/Sub-array Division/solution.java +++ b/Algorithms/Implementation/Sub-array Division/solution.java @@ -1,41 +1,41 @@ -import java.util.*; - -public class Solution { - - public static int getNumberOfWays(int n, int d, int m, int[] sum) { - // Modify array to make each 'i' contain the running sum of prior elements - for (int i = 1; i < n; i++) { - sum[i] += sum[i - 1]; - } - - // Set number of ways counter - // If there are >= 'm' squares AND the first possible piece has sum = 'd', 1 - // Else, 0 - int numberOfWays = (m <= n && sum[m - 1] == d) ? 1 : 0; - - // Check the sums for pieces ending at index 'm' through 'n - 1' - for (int i = m; i < n; i++) { - // If the sum of the piece is equal to 'd' - if (sum[i] - sum[i - m] == d) { - // Increment ways counter - numberOfWays++; - } - } - - return numberOfWays; - } - - public static void main(String[] args) { - Scanner in = new Scanner(System.in); - int n = in.nextInt(); - int[] squares = new int[n]; - for(int squares_i=0; squares_i < n; squares_i++){ - squares[squares_i] = in.nextInt(); - } - int d = in.nextInt(); - int m = in.nextInt(); - in.close(); - - System.out.println(getNumberOfWays(n, d, m, squares)); - } +import java.util.*; + +public class Solution { + + public static int getNumberOfWays(int n, int d, int m, int[] sum) { + // Modify array to make each 'i' contain the running sum of prior elements + for (int i = 1; i < n; i++) { + sum[i] += sum[i - 1]; + } + + // Set number of ways counter + // If there are >= 'm' squares AND the first possible piece has sum = 'd', 1 + // Else, 0 + int numberOfWays = (m <= n && sum[m - 1] == d) ? 1 : 0; + + // Check the sums for pieces ending at index 'm' through 'n - 1' + for (int i = m; i < n; i++) { + // If the sum of the piece is equal to 'd' + if (sum[i] - sum[i - m] == d) { + // Increment ways counter + numberOfWays++; + } + } + + return numberOfWays; + } + + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + int n = in.nextInt(); + int[] squares = new int[n]; + for(int squares_i=0; squares_i < n; squares_i++){ + squares[squares_i] = in.nextInt(); + } + int d = in.nextInt(); + int m = in.nextInt(); + in.close(); + + System.out.println(getNumberOfWays(n, d, m, squares)); + } } \ No newline at end of file diff --git a/Algorithms/Sub-array Division/solution.py b/Algorithms/Implementation/Sub-array Division/solution.py similarity index 100% rename from Algorithms/Sub-array Division/solution.py rename to Algorithms/Implementation/Sub-array Division/solution.py diff --git a/Algorithms/Minimum Loss/solution.cpp b/Algorithms/Search/Minimum Loss/solution.cpp similarity index 100% rename from Algorithms/Minimum Loss/solution.cpp rename to Algorithms/Search/Minimum Loss/solution.cpp diff --git a/Algorithms/Minimum Loss/solution.java b/Algorithms/Search/Minimum Loss/solution.java similarity index 100% rename from Algorithms/Minimum Loss/solution.java rename to Algorithms/Search/Minimum Loss/solution.java diff --git a/Algorithms/Minimum Loss/solution.py b/Algorithms/Search/Minimum Loss/solution.py similarity index 100% rename from Algorithms/Minimum Loss/solution.py rename to Algorithms/Search/Minimum Loss/solution.py diff --git a/Algorithms/Birthday Cake Candles/solution.cpp b/Algorithms/Warmup/Birthday Cake Candles/solution.cpp similarity index 100% rename from Algorithms/Birthday Cake Candles/solution.cpp rename to Algorithms/Warmup/Birthday Cake Candles/solution.cpp diff --git a/Algorithms/Birthday Cake Candles/solution.java b/Algorithms/Warmup/Birthday Cake Candles/solution.java similarity index 97% rename from Algorithms/Birthday Cake Candles/solution.java rename to Algorithms/Warmup/Birthday Cake Candles/solution.java index c09c737e..c9e29f19 100644 --- a/Algorithms/Birthday Cake Candles/solution.java +++ b/Algorithms/Warmup/Birthday Cake Candles/solution.java @@ -1,50 +1,50 @@ -import java.io.*; -import java.math.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.function.*; -import java.util.regex.*; -import java.util.stream.*; -import static java.util.stream.Collectors.joining; -import static java.util.stream.Collectors.toList; - -class Result { - - //Method to return the number of tallest candles - public static int birthdayCakeCandles(List candles) { - // We will set the maxcount and max size of candle to zero - int max = candles.get(0), maxCount = 1; - // We will iterate through the array and update the tallest candle and its count - for(int i = 1; i < candles.size(); i ++) { - if(max < candles.get(i)) - { - max = candles.get(i); - maxCount = 1; - } - else if(max == candles.get(i)) { - maxCount ++; - } - } - //Finally return the max Count - return maxCount; - } -} - -/* Driver Code */ -public class Solution { - public static void main(String[] args) throws IOException { - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); - int candlesCount = Integer.parseInt(bufferedReader.readLine().trim()); - List candles = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" ")) - .map(Integer::parseInt) - .collect(toList()); - int result = Result.birthdayCakeCandles(candles); - bufferedWriter.write(String.valueOf(result)); - bufferedWriter.newLine(); - bufferedReader.close(); - bufferedWriter.close(); - } -} +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.function.*; +import java.util.regex.*; +import java.util.stream.*; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toList; + +class Result { + + //Method to return the number of tallest candles + public static int birthdayCakeCandles(List candles) { + // We will set the maxcount and max size of candle to zero + int max = candles.get(0), maxCount = 1; + // We will iterate through the array and update the tallest candle and its count + for(int i = 1; i < candles.size(); i ++) { + if(max < candles.get(i)) + { + max = candles.get(i); + maxCount = 1; + } + else if(max == candles.get(i)) { + maxCount ++; + } + } + //Finally return the max Count + return maxCount; + } +} + +/* Driver Code */ +public class Solution { + public static void main(String[] args) throws IOException { + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); + int candlesCount = Integer.parseInt(bufferedReader.readLine().trim()); + List candles = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" ")) + .map(Integer::parseInt) + .collect(toList()); + int result = Result.birthdayCakeCandles(candles); + bufferedWriter.write(String.valueOf(result)); + bufferedWriter.newLine(); + bufferedReader.close(); + bufferedWriter.close(); + } +} diff --git a/Algorithms/Birthday Cake Candles/solution.py b/Algorithms/Warmup/Birthday Cake Candles/solution.py similarity index 100% rename from Algorithms/Birthday Cake Candles/solution.py rename to Algorithms/Warmup/Birthday Cake Candles/solution.py diff --git a/Algorithms/Diagonal Difference/Solution.java b/Algorithms/Warmup/Diagonal Difference/Solution.java similarity index 100% rename from Algorithms/Diagonal Difference/Solution.java rename to Algorithms/Warmup/Diagonal Difference/Solution.java diff --git a/Algorithms/Diagonal Difference/solution.cpp b/Algorithms/Warmup/Diagonal Difference/solution.cpp similarity index 100% rename from Algorithms/Diagonal Difference/solution.cpp rename to Algorithms/Warmup/Diagonal Difference/solution.cpp diff --git a/Algorithms/Diagonal Difference/solution.py b/Algorithms/Warmup/Diagonal Difference/solution.py similarity index 100% rename from Algorithms/Diagonal Difference/solution.py rename to Algorithms/Warmup/Diagonal Difference/solution.py diff --git a/Algorithms/Mini-Max Sum/solution.cpp b/Algorithms/Warmup/Mini-Max Sum/solution.cpp similarity index 100% rename from Algorithms/Mini-Max Sum/solution.cpp rename to Algorithms/Warmup/Mini-Max Sum/solution.cpp diff --git a/Algorithms/Mini-Max Sum/solution.java b/Algorithms/Warmup/Mini-Max Sum/solution.java similarity index 96% rename from Algorithms/Mini-Max Sum/solution.java rename to Algorithms/Warmup/Mini-Max Sum/solution.java index cefd4b7c..aa188464 100644 --- a/Algorithms/Mini-Max Sum/solution.java +++ b/Algorithms/Warmup/Mini-Max Sum/solution.java @@ -1,41 +1,41 @@ -import java.io.*; -import java.math.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.regex.*; - -public class Solution { - - // Complete the miniMaxSum function below. - static void miniMaxSum(int[] arr) { - //Set the min, max and sum - long sum = 0; - long min = Integer.MAX_VALUE; - long max = Integer.MIN_VALUE; - //Iterate through the array and update the sum, min and max - for (int i = 0; i < arr.length; i++) { - long num = arr[i]; - sum += num; - min = Math.min(min, num); - max = Math.max(max, num); - } - //Finally print out the difference between (sum and max) and (sum and min) - System.out.print((sum - max) + " " + (sum - min)); - } - - /* Driver Code */ - private static final Scanner scanner = new Scanner(System.in); - public static void main(String[] args) { - int[] arr = new int[5]; - String[] arrItems = scanner.nextLine().split(" "); - scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); - for (int i = 0; i < 5; i++) { - int arrItem = Integer.parseInt(arrItems[i]); - arr[i] = arrItem; - } - miniMaxSum(arr); - scanner.close(); - } -} +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + // Complete the miniMaxSum function below. + static void miniMaxSum(int[] arr) { + //Set the min, max and sum + long sum = 0; + long min = Integer.MAX_VALUE; + long max = Integer.MIN_VALUE; + //Iterate through the array and update the sum, min and max + for (int i = 0; i < arr.length; i++) { + long num = arr[i]; + sum += num; + min = Math.min(min, num); + max = Math.max(max, num); + } + //Finally print out the difference between (sum and max) and (sum and min) + System.out.print((sum - max) + " " + (sum - min)); + } + + /* Driver Code */ + private static final Scanner scanner = new Scanner(System.in); + public static void main(String[] args) { + int[] arr = new int[5]; + String[] arrItems = scanner.nextLine().split(" "); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + for (int i = 0; i < 5; i++) { + int arrItem = Integer.parseInt(arrItems[i]); + arr[i] = arrItem; + } + miniMaxSum(arr); + scanner.close(); + } +} diff --git a/Algorithms/Mini-Max Sum/solution.py b/Algorithms/Warmup/Mini-Max Sum/solution.py similarity index 100% rename from Algorithms/Mini-Max Sum/solution.py rename to Algorithms/Warmup/Mini-Max Sum/solution.py diff --git a/README.md b/README.md index 21eadce5..cdb12302 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Please read [contribution guidelines](CONTRIBUTING.md) for contributing to the p ||[QHEAP1](https://www.hackerrank.com/challenges/qheap1/problem)|Easy|[View](Heap/QHEAP1/solution.cpp)|[View](Heap/QHEAP1/solution.java)|[View](Heap/QHEAP1/solution.py)| ||[Jesse and Cookies](https://www.hackerrank.com/challenges/jesse-and-cookies/problem)|Easy|[View](Heap/Jesse%20and%20Cookies/solution.cpp)|[View](Heap/Jesse%20and%20Cookies/solution.java)|[View](Heap/Jesse%20and%20Cookies/solution.py)| ||[Find the Running Median](https://www.hackerrank.com/challenges/find-the-running-median/problem)|Hard|[View](Heap/Find%20the%20Running%20Median/solution.cpp)|[View](Heap/Find%20the%20Running%20Median/solution.java)|[View](Heap/Find%20the%20Running%20Median/solution.py)| +||[Minimum Average Waiting Time](https://www.hackerrank.com/challenges/minimum-average-waiting-time/problem)|Hard|||[View](/Heap/Minimum%20Average%20Waiting%20Time/solution.py)| | Trees | ||[Tree - Top View](https://www.hackerrank.com/challenges/tree-top-view/problem)|Easy|[View](Trees/Tree-Top%20View/solution.cpp)|[View](Trees/Tree-Top%20View/solution.java)|[View](Trees/Tree-Top%20View/solution.py)| ||[Tree - Preorder Traversal](https://www.hackerrank.com/challenges/tree-preorder-traversal/problem)|Easy|[View](/Trees/Tree-Preorder%20Traversal/solution.cpp)|[View](/Trees/Tree-Preorder%20Traversal/solution.java)|[View](/Trees/Tree-Preorder%20Traversal/solution.py)| @@ -73,42 +74,42 @@ Please read [contribution guidelines](CONTRIBUTING.md) for contributing to the p ||[Contacts](https://www.hackerrank.com/challenges/contacts/problem)|Medium|[View](/Trie/Contacts/solution.cpp)||| ||[No Prefix Set](https://www.hackerrank.com/challenges/no-prefix-set/problem)|Hard|[View](/Trie/No%20Prefix%20Set/solution.cpp)||| | Algorithms | -||[Mark and Toys]( https://www.hackerrank.com/challenges/mark-and-toys/problem)|Easy|[View](/Algorithms/Greedy/Mark%20and%20Toys/solution.cpp)|[View](/Algorithms/Greedy/Mark%20and%20Toys/solution.java)|[View](/Algorithms/Greedy/Mark%20and%20Toys/solution.py)| -||[Grading Students](https://www.hackerrank.com/challenges/grading/problem)|Easy|[View](/Algorithms/Greedy/Grading%20Students/solution.cpp)|[View](/Algorithms/Grading%20Students/solution.java)|[View](/Algorithms/Grading%20Students/solution.py)| -||[Apple and Orange](https://www.hackerrank.com/challenges/apple-and-orange/problem)|Easy|[View](/Algorithms/Apple%20and%20Orange/solution.cpp)|[View](Algorithms/Apple%20and%20Orange/solution.java)|[View](/Algorithms/Apple%20and%20Orange/solution.py)| -||[Number Line Jumps](https://www.hackerrank.com/challenges/kangaroo/problem)|Easy|[View](Algorithms/Number%20Line%20Jump/solution.cpp)|[View](Algorithms/Number%20Line%20Jump/solution.java)|[View](Algorithms/Number%20Line%20Jump/solution.py)| -||[Encryption](https://www.hackerrank.com/challenges/encryption/problem)|Medium|[View](Algorithms/Implementation/Encryption/solution.cpp)||[View](Algorithms/Encryption/solution.py)| -||[Cut the sticks](https://www.hackerrank.com/challenges/cut-the-sticks/problem)|Easy|[View](/Algorithms/Implementation/Cut%20the%20sticks/solution.cpp)|[View](/Algorithms/Implementation/Cut%20the%20sticks/solution.java)|[View](/Algorithms/Implementation/Cut%20the%20sticks/solution.py)| -||[Breaking the Records](https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem)|Easy|[View](/Algorithms/Breaking%20the%20Records/solution.cpp)|[View](/Algorithms/Breaking%20the%20Records/solution.java)|| -||[Sales by Match](https://www.hackerrank.com/challenges/sock-merchant/problem)|Easy|[View](/Algorithms/Sales%20by%20Match/solution.cpp)|[View](/Algorithms/Sales%20by%20Match/solution.java)|| -||[Climbing the Leaderboard](https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem)|Medium|[View](/Algorithms/Climbing%20the%20Leaderboard/solution.cpp)|[View](/Algorithms/Climbing%20the%20Leaderboard/solution.java)|[View](/Algorithms/Climbing%20the%20Leaderboard/solution.py)| -||[Diagonal Difference](https://www.hackerrank.com/challenges/diagonal-difference/problem)|Easy|[View](Algorithms/Diagonal%20Difference/solution.cpp)|[View](/Algorithms/Diagonal%20Difference/solution.java)|[View](/Algorithms/Diagonal%20Difference/solution.py)| -||[Queen's Attack II](https://www.hackerrank.com/challenges/queens-attack-2/problem)|Medium|[View](Algorithms/Queen's%20Attack%20II/solution.cpp)|[View](Algorithms/Queen's%20Attack%20II/solution.java)|[View](Algorithms/Queen's%20Attack%20II/solution.py)| -||[Electronics Shop](https://www.hackerrank.com/challenges/electronics-shop/problem)|Easy|[View](Algorithms/Electronics%20Shop/solution.cpp)|[View](Algorithms/Electronics%20Shop/solution.java)|[View](Algorithms/Electronics%20Shop/solution.py)| -||[The Coin change problem](https://www.hackerrank.com/challenges/grading/problem)|Medium|[View](/Algorithms/The%20coin%20change%20problem/solution.cpp)|[View](/Algorithms/The%20coin%20change%20problem/solution.java)|[View](/Algorithms/The%20coin%20change%20problem/solution.py)| -||[Angry Professor](https://www.hackerrank.com/challenges/angry-professor/problem)|Easy|[View](/Algorithms/Angry%20Professor/solution.cpp)|[View](/Algorithms/Angry%20Professor/solution.java)|[View](/Algorithms/Angry%20Professor/solution.py)| -||[Migratory Birds](https://www.hackerrank.com/challenges/migratory-birds/problem)|Easy|[View](/Algorithms/Migratory%20Birds/solution.cpp)|[View](/Algorithms/Migratory%20Birds/solution.java)|[View](/Algorithms/Migratory%20Birds/solution.py)| -||[Mini-Max Sum](https://www.hackerrank.com/challenges/mini-max-sum/problem)|Easy|[View](Algorithms/Mini-Max%20Sum/solution.cpp)|[View](Algorithms/Mini-Max%20Sum/solution.java)|[View](/Algorithms/Mini-Max%20Sum/solution.py)| +||[Mark and Toys]( https://www.hackerrank.com/challenges/mark-and-toys/problem)|Easy|[View](Algorithms/Greedy/Mark%20and%20Toys/solution.cpp)|[View](Algorithms/Greedy/Mark%20and%20Toys/solution.java)|[View](Algorithms/Greedy/Mark%20and%20Toys/solution.py)| +||[Grading Students](https://www.hackerrank.com/challenges/grading/problem)|Easy|[View](Algorithms/Implementation/Grading%20Students/solution.cpp)|[View](Algorithms/Implementation/Grading%20Students/solution.java)|[View](Algorithms/Implementation/Grading%20Students/solution.py)| +||[Apple and Orange](https://www.hackerrank.com/challenges/apple-and-orange/problem)|Easy|[View](Algorithms/Implementation/Apple%20and%20Orange/solution.cpp)|[View](Algorithms/Implementation/Apple%20and%20Orange/solution.java)|[View](Algorithms/Implementation/Apple%20and%20Orange/solution.py)| +||[Number Line Jumps](https://www.hackerrank.com/challenges/kangaroo/problem)|Easy|[View](Algorithms/Number%20Line%20Jumps/solution.cpp)|[View](Algorithms/Number%20Line%20Jumps/solution.java)|[View](Algorithms/Number%20Line%20Jumps/solution.py)| +||[Encryption](https://www.hackerrank.com/challenges/encryption/problem)|Medium|[View](Algorithms/Implementation/Encryption/solution.cpp)||[View](Algorithms/Implementation/Encryption/solution.py)| +||[Cut the sticks](https://www.hackerrank.com/challenges/cut-the-sticks/problem)|Easy|[View](Algorithms/Implementation/Cut%20the%20sticks/solution.cpp)|[View](Algorithms/Implementation/Cut%20the%20sticks/solution.java)|[View](Algorithms/Implementation/Cut%20the%20sticks/solution.py)| +||[Breaking the Records](https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem)|Easy|[View](Algorithms/Implementation/Breaking%20the%20Records/solution.cpp)|[View](Algorithms/Implementation/Breaking%20the%20Records/solution.java)|[View](Algorithms/Implementation/Breaking%20the%20Records/solution.py)| +||[Sales by Match](https://www.hackerrank.com/challenges/sock-merchant/problem)|Easy|[View](Algorithms/Implementation/Sales%20by%20Match/solution.cpp)|[View](Algorithms/Implementation/Sales%20by%20Match/solution.java)|[View](Algorithms/Implementation/Sales%20by%20Match/solution.java)| +||[Climbing the Leaderboard](https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem)|Medium|[View](Algorithms/Implementation/Climbing%20the%20Leaderboard/solution.cpp)|[View](/Algorithms/Implementation/Climbing%20the%20Leaderboard/solution.java)|[View](/Algorithms/Implementation/Climbing%20the%20Leaderboard/solution.py)| +||[Diagonal Difference](https://www.hackerrank.com/challenges/diagonal-difference/problem)|Easy|[View](Algorithms/Warmup/Diagonal%20Difference/solution.cpp)|[View](Algorithms/Warmup/Diagonal%20Difference/solution.java)|[View](Algorithms/Warmup/Diagonal%20Difference/solution.py)| +||[Queen's Attack II](https://www.hackerrank.com/challenges/queens-attack-2/problem)|Medium|[View](Algorithms/Implementation/Queen's%20Attack%20II/solution.cpp)|[View](Algorithms/Implementation/Queen's%20Attack%20II/solution.java)|[View](Algorithms/Implementation/Queen's%20Attack%20II/solution.py)| +||[Electronics Shop](https://www.hackerrank.com/challenges/electronics-shop/problem)|Easy|[View](Algorithms/Implementation/Electronics%20Shop/solution.cpp)|[View](Algorithms/Implementation/Electronics%20Shop/solution.java)|[View](Algorithms/Implementation/Electronics%20Shop/solution.py)| +||[The Coin Change Problem](https://www.hackerrank.com/challenges/grading/problem)|Medium|[View](Algorithms/Dynamic%20Programming/The%20Coin%20Change%20Problem/solution.cpp)|[View](Algorithms/Dynamic%20Programming/The%20Coin%20Change%20Problem/solution.java)|[View](Algorithms/Dynamic%20Programming/The%20Coin%20Change%20Problem/solution.py)| +||[Angry Professor](https://www.hackerrank.com/challenges/angry-professor/problem)|Easy|[View](Algorithms/Implementation/Angry%20Professor/solution.cpp)|[View](Algorithms/Implementation/Angry%20Professor/solution.java)|[View](Algorithms/Implementation/Angry%20Professor/solution.py)| +||[Migratory Birds](https://www.hackerrank.com/challenges/migratory-birds/problem)|Easy|[View](Algorithms/Implementation/Migratory%20Birds/solution.cpp)|[View](Algorithms/Implementation/Migratory%20Birds/solution.java)|[View](Algorithms/Implementation/Migratory%20Birds/solution.py)| +||[Mini-Max Sum](https://www.hackerrank.com/challenges/mini-max-sum/problem)|Easy|[View](Algorithms/Warmup/Mini-Max%20Sum/solution.cpp)|[View](Algorithms/Warmup/Mini-Max%20Sum/solution.java)|[View](Algorithms/Warmup/Mini-Max%20Sum/solution.py)| ||[Dorsey Thief](https://www.hackerrank.com/challenges/dorsey-thief/problem)|Advanced|[View](Algorithms/Dynamic%20Programming/Dorsey%20Thief/solution.cpp)|[View](Algorithms/Dynamic%20Programming/Dorsey%20Thief/Solution.java)|| -||[Luck Balance](https://www.hackerrank.com/challenges/luck-balance/problem)|Easy|[View](Algorithms/Luck%20Balance/solution.cpp)|[View](Algorithms/Luck%20Balance/solution.java)|[View](Algorithms/Luck%20Balance/solution.py)| +||[Luck Balance](https://www.hackerrank.com/challenges/luck-balance/problem)|Easy|[View](Algorithms/Greedy/Luck%20Balance/solution.cpp)|[View](Algorithms/Greedy/Luck%20Balance/solution.java)|[View](Algorithms/Greedy/Luck%20Balance/solution.py)| ||[Fair Cut](https://www.hackerrank.com/challenges/fair-cut/problem)|Medium|[View](Algorithms/Dynamic%20Programming/Fair%20Cut/solution.cpp)|[View](Algorithms/Dynamic%20Programming/Fair%20Cut/solution.java)|[View](Algorithms/Dynamic%20Programming/Fair%20Cut/solution.py)| ||[Prime XOR](https://www.hackerrank.com/challenges/prime-xor/problem)|Medium|[View](Algorithms/Dynamic%20Programming/Prime%20XOR/solution.cpp)|[View](Algorithms/Dynamic%20Programming/Prime%20XOR/solution.java)|[View](Algorithms/Dynamic%20Programming/Prime%20XOR/solution.py)| -||[The Great XOR](https://www.hackerrank.com/challenges/the-great-xor/problem)|Medium|[View](/Algorithms/Bit%20Manipulation/The%20Great%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/The%20Great%20XOR/solution.java)|[View](/Algorithms/Bit%20Manipulation/The%20Great%20XOR/solution.py)| -||[Sansa and XOR](https://www.hackerrank.com/challenges/sansa-and-xor/problem)|Medium|[View](/Algorithms/Bit%20Manipulation/Sansa%20and%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Sansa%20and%20XOR/solution.java)|[View](Algorithms/Bit%20Manipulation/Sansa%20and%20XOR/solution.py)| -||[Xor sequence](https://www.hackerrank.com/challenges/xor-se/problem)|Medium|[View](/Algorithms/Bit%20Manipulation/Xor%20sequence/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Xor%20sequence/solution.java)|[View](/Algorithms/Bit%20Manipulation/Xor%20sequence/solution.py)| -||[Sherlock and the Valid String](https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem)|Medium|[View](/Algorithms/Strings/Sherlock%20and%20the%20Valid%20String/solution.cpp)|[View](/Algorithms/Strings/Sherlock%20and%20the%20Valid%20String/solution.java)|[View](/Algorithms/Strings/Sherlock%20and%20the%20Valid%20String/solution.py)| +||[The Great XOR](https://www.hackerrank.com/challenges/the-great-xor/problem)|Medium|[View](Algorithms/Bit%20Manipulation/The%20Great%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/The%20Great%20XOR/solution.java)|[View](Algorithms/Bit%20Manipulation/The%20Great%20XOR/solution.py)| +||[Sansa and XOR](https://www.hackerrank.com/challenges/sansa-and-xor/problem)|Medium|[View](Algorithms/Bit%20Manipulation/Sansa%20and%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Sansa%20and%20XOR/solution.java)|[View](Algorithms/Bit%20Manipulation/Sansa%20and%20XOR/solution.py)| +||[Xor-sequence](https://www.hackerrank.com/challenges/xor-se/problem)|Medium|[View](Algorithms/Bit%20Manipulation/Xor-sequence/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Xor-sequence/solution.java)|[View](Algorithms/Bit%20Manipulation/Xor-sequence/solution.py)| +||[Sherlock and the Valid String](https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem)|Medium|[View](Algorithms/Strings/Sherlock%20and%20the%20Valid%20String/solution.cpp)|[View](Algorithms/Strings/Sherlock%20and%20the%20Valid%20String/solution.java)|[View](Algorithms/Strings/Sherlock%20and%20the%20Valid%20String/solution.py)| ||[Bigger is Greater](https://www.hackerrank.com/challenges/bigger-is-greater/problem)|Medium|[View](Algorithms/Implementation/Bigger%20is%20Greater/solution.cpp)|[View](Algorithms/Implementation/Bigger%20is%20Greater/solution.java)|[View](Algorithms/Implementation/Bigger%20is%20Greater/solution.py)| ||[Utopian Tree](https://www.hackerrank.com/challenges/utopian-tree/problem)|Easy|[View](Algorithms/Implementation/Utopian%20Tree/solution.cpp)|[View](Algorithms/Implementation/Utopian%20Tree/solution.java)|[View](Algorithms/Implementation/Utopian%20Tree/solution.py)| ||[Sequence Equation](https://www.hackerrank.com/challenges/permutation-equation/problem)|Easy|[View](Algorithms/Implementation/Sequence%20Equation/solution.cpp)|[View](Algorithms/Implementation/Sequence%20Equation/solution.java)|[View](Algorithms/Implementation/Sequence%20Equation/solution.py)| ||[Find Digits](https://www.hackerrank.com/challenges/find-digits/problem)|Easy|[View](Algorithms/Implementation/Find%20Digits/solution.cpp)|[View](Algorithms/Implementation/Find%20Digits/solution.java)|[View](Algorithms/Implementation/Find%20Digits/solution.py)| ||[Modified Kaprekar Numbers](https://www.hackerrank.com/challenges/kaprekar-numbers/problem)|Easy|[View](Algorithms/Implementation/Modified%20Kaprekar%20Numbers/solution.cpp)|[View](Algorithms/Implementation/Modified%20Kaprekar%20Numbers/solution.java)|[View](Algorithms/Implementation/Modified%20Kaprekar%20Numbers/solution.py)| ||[Taum and B'day](https://www.hackerrank.com/challenges/taum-and-bday/problem)|Easy|[View](Algorithms/Implementation/Taum%20and%20B'day/solution.cpp)|[View](Algorithms/Implementation/Taum%20and%20B'day/solution.java)|[View](Algorithms/Implementation/Taum%20and%20B'day/solution.py)| -||[Jumping on the Clouds](https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem)|Easy|[View](Algorithms/Implementation/Jumping%20on%20the%20Clouds/solution.cpp)||[View](/Algorithms/Implementation/Jumping%20on%20the%20Clouds/solution.py)| -||[Repeated String](https://www.hackerrank.com/challenges/repeated-string/problem)|Easy|[View](Algorithms/Implementation/Repeated%20String/solution.cpp)||[View](/Algorithms/Implementation/Repeated%20String/solution.py)| +||[Jumping on the Clouds](https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem)|Easy|[View](Algorithms/Implementation/Jumping%20on%20the%20Clouds/solution.cpp)||[View](Algorithms/Implementation/Jumping%20on%20the%20Clouds/solution.py)| +||[Repeated String](https://www.hackerrank.com/challenges/repeated-string/problem)|Easy|[View](Algorithms/Implementation/Repeated%20String/solution.cpp)||[View](Algorithms/Implementation/Repeated%20String/solution.py)| ||[Jim and the Orders](https://www.hackerrank.com/challenges/jim-and-the-orders/problem)|Easy|[View](Algorithms/Greedy/Jim%20and%20the%20Orders/solution.cpp)|[View](Algorithms/Greedy/Jim%20and%20the%20Orders/solution.java)|[View](Algorithms/Greedy/Jim%20and%20the%20Orders/solution.py)| -||[Sherlock and Array](https://www.hackerrank.com/challenges/sherlock-and-array/problem)|Easy|[View](Algorithms/Search/Sherlock%20and%20Array/solution.cpp)|[View](Algorithms/Search/Sherlock%20and%20Array/solution.java)|[View](/Algorithms/Search/Sherlock%20and%20Array/solution.py)| -||[Ice Cream Parlor](https://www.hackerrank.com/challenges/icecream-parlor/problem)|Easy|[View](Algorithms/Search/Ice%20Cream%20Parlor/solution.cpp)|[View](Algorithms/Search/Ice%20Cream%20Parlor/solution.java)|[View](/Algorithms/Search/Ice%20Cream%20Parlor/solution.py)| -||[Missing Numbers](https://www.hackerrank.com/challenges/missing-numbers/problem)|Easy|[View](Algorithms/Search/Missing%20Numbers/solution.cpp)|[View](Algorithms/Search/Missing%20Numbers/solution.java)|[View](/Algorithms/Search/Missing%20Numbers/solution.py)| +||[Sherlock and Array](https://www.hackerrank.com/challenges/sherlock-and-array/problem)|Easy|[View](Algorithms/Search/Sherlock%20and%20Array/solution.cpp)|[View](Algorithms/Search/Sherlock%20and%20Array/solution.java)|[View](Algorithms/Search/Sherlock%20and%20Array/solution.py)| +||[Ice Cream Parlor](https://www.hackerrank.com/challenges/icecream-parlor/problem)|Easy|[View](Algorithms/Search/Ice%20Cream%20Parlor/solution.cpp)|[View](Algorithms/Search/Ice%20Cream%20Parlor/solution.java)|[View](Algorithms/Search/Ice%20Cream%20Parlor/solution.py)| +||[Missing Numbers](https://www.hackerrank.com/challenges/missing-numbers/problem)|Easy|[View](Algorithms/Search/Missing%20Numbers/solution.cpp)|[View](Algorithms/Search/Missing%20Numbers/solution.java)|[View](Algorithms/Search/Missing%20Numbers/solution.py)| ||[Making Anagrams](https://www.hackerrank.com/challenges/making-anagrams/problem)|Easy|[View](Algorithms/Strings/Making%20Anagrams/solution.cpp)|[View](Algorithms/Strings/Making%20Anagrams/solution.java)|| ||[The Love-Letter Mystery](https://www.hackerrank.com/challenges/the-love-letter-mystery/problem)|Easy|[View](Algorithms/Strings/The%20Love-Letter%20Mystery/solution.cpp)|[View](Algorithms/Strings/The%20Love-Letter%20Mystery/solution.java)|| ||[Beautiful Binary String](https://www.hackerrank.com/challenges/beautiful-binary-string/problem)|Easy|[View](Algorithms/Strings/Beautiful%20Binary%20String/solution.cpp)|[View](Algorithms/Strings/Beautiful%20Binary%20String/solution.java)|| @@ -117,47 +118,46 @@ Please read [contribution guidelines](CONTRIBUTING.md) for contributing to the p ||[Gemstones](https://www.hackerrank.com/challenges/gem-stones/problem)|Easy|[View](Algorithms/Strings/Gemstones/solution.cpp)|[View](Algorithms/Strings/Gemstones/solution.java)|[View](Algorithms/Strings/Gemstones/solution.py)| ||[Pangrams](https://www.hackerrank.com/challenges/pangrams/problem)|Easy|[View](Algorithms/Strings/Pangrams/solution.cpp)|[View](Algorithms/Strings/Pangrams/solution.java)|[View](Algorithms/Strings/Pangrams/solution.py)| ||[Largest Permutation](https://www.hackerrank.com/challenges/largest-permutation/problem)|Easy|[View](Algorithms/Greedy/Largest%20Permutation/solution.cpp)|[View](Algorithms/Greedy/Largest%20Permutation/solution.java)|[View](Algorithms/Greedy/Largest%20Permutation/solution.py)| -||[Running Time of Algorithms](https://www.hackerrank.com/challenges/runningtime/problem)|Easy|[View](Algorithms/Sorting/Running%20Time%20of%20Algorithms/solution.cpp)|[View](Algorithms/Sorting/Running%20Time%20of%20Algorithms/solution.java)|[View](/Algorithms/Sorting/Running%20Time%20of%20Algorithms/solution.py)| -||[Correctness and the Loop Invariant](https://www.hackerrank.com/challenges/correctness-invariant/problem)|Easy|[View](Algorithms/Sorting/Correctness%20and%20the%20Loop%20Invariant/solution.cpp)|[View](Algorithms/Sorting/Correctness%20and%20the%20Loop%20Invariant/solution.java)|[View](/Algorithms/Sorting/Correctness%20and%20the%20Loop%20Invariant/solution.py)| +||[Running Time of Algorithms](https://www.hackerrank.com/challenges/runningtime/problem)|Easy|[View](Algorithms/Sorting/Running%20Time%20of%20Algorithms/solution.cpp)|[View](Algorithms/Sorting/Running%20Time%20of%20Algorithms/solution.java)|[View](Algorithms/Sorting/Running%20Time%20of%20Algorithms/solution.py)| +||[Correctness and the Loop Invariant](https://www.hackerrank.com/challenges/correctness-invariant/problem)|Easy|[View](Algorithms/Sorting/Correctness%20and%20the%20Loop%20Invariant/solution.cpp)|[View](Algorithms/Sorting/Correctness%20and%20the%20Loop%20Invariant/solution.java)|[View](Algorithms/Sorting/Correctness%20and%20the%20Loop%20Invariant/solution.py)| ||[The Hurdle Race](https://www.hackerrank.com/challenges/the-hurdle-race/problem)|Easy|[View](Algorithms/Implementation/The%20Hurdle%20Race/solution.cpp)||[View](Algorithms/Implementation/The%20Hurdle%20Race/solution.py)| ||[Designer PDF Viewer](https://www.hackerrank.com/challenges/designer-pdf-viewer/problem)|Easy|[View](Algorithms/Implementation/Designer%20PDF%20Viewer/solution.cpp)||[View](Algorithms/Implementation/Designer%20PDF%20Viewer/solution.py)| ||[The Power Sum](https://www.hackerrank.com/challenges/the-power-sum/problem)|Medium|[View](Algorithms/Recursion/The%20Power%20Sum/solution.cpp)|[View](Algorithms/Recursion/The%20Power%20Sum/solution.java)|| ||[Crossword Puzzle](https://www.hackerrank.com/challenges/crossword-puzzle/problem)|Medium|[View](Algorithms/Recursion/Crossword%20Puzzle/solution.cpp)|[View](Algorithms/Recursion/Crossword%20Puzzle/solution.java)|| -||[Closest Numbers](https://www.hackerrank.com/challenges/closest-numbers/problem)|Easy|[View](Algorithms/Sorting/Closest%20Numbers/solution.cpp)|[View](Algorithms/Sorting/Closest%20Numbers/solution.java)|[View](/Algorithms/Sorting/Closest%20Numbers/solution.py)| -||[CamelCase](https://www.hackerrank.com/challenges/camelcase/problem)|Easy|[View](Algorithms/Strings/CamelCase/solution.cpp)|[View](Algorithms/Strings/CamelCase/solution.java)|[View](/Algorithms/Strings/CamelCase/solution.py)| -||[Lonely Integer](https://www.hackerrank.com/challenges/lonely-integer/problem)|Easy|[View](/Algorithms/Lonely%20Integer/solution.cpp)|[View](/Algorithms/Lonely%20Integer/solution.java)|[View](/Algorithms/Lonely%20Integer/solution.py)| -||[Sum vs XOR](https://www.hackerrank.com/challenges/sum-vs-xor/problem)|Easy|[View](Algorithms/Bit%20Manipulation/Sum%20vs%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Sum%20vs%20XOR/solution.java)|[View](/Algorithms/Bit%20Manipulation/Sum%20vs%20XOR/solution.py)| -||[Maximizing XOR](https://www.hackerrank.com/challenges/maximizing-xor/problem)|Easy|[View](/Algorithms/Bit%20Manipulation/Maximizing%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Maximizing%20XOR/solution.java)|[View](/Algorithms/Bit%20Manipulation/Maximizing%20XOR/solution.py)| -||[Birthday Cake Candles](https://www.hackerrank.com/challenges/birthday-cake-candles/problem)|Easy|[View](Algorithms/Birthday%20Cake%20Candles/solution.cpp)|[View](Algorithms/Birthday%20Cake%20Candles/solution.java)|[View](/Algorithms/Birthday%20Cake%20Candles/solution.py)| -||[Sub-array Division](https://www.hackerrank.com/challenges/the-birthday-bar/problem)|Easy|[View](/Algorithms/Sub-array%20Division/solution.cpp)|[View](Algorithms/Sub-array%20Division/solution.java)|[View](/Algorithms/Sub-array%20Division/solution.py)| -||[Bill Division](https://www.hackerrank.com/challenges/bon-apetit/problem)|Easy|[View](/Algorithms/Sub-array%20Division/solution.cpp)|[View](Algorithms/Bill%20Division/solution.java)|[View](/Algorithms/Bill%20Division/solution.py)| -||[Marc's Cakewalk](https://www.hackerrank.com/challenges/marcs-cakewalk/problem)|Easy|[View](/Algorithms/Marc's%20Cakewalk/solution.cpp)|[View](Algorithms/Marc's%20Cakewalk/solution.java)|[View](Algorithms/Marc's%20Cakewalk/solution.py)| -||[Flipping Bits](https://www.hackerrank.com/challenges/flipping-bits/problem)|Easy|[View](/Algorithms/Bit%20Manipulation/Flipping%20Bits/solution.cpp)|[View](/Algorithms/Bit%20Manipulation/Flipping%20Bits/solution.java)|[View](/Algorithms/Bit%20Manipulation/Flipping%20Bits/solution.py)| -||[The Longest Common Subsequence](https://www.hackerrank.com/challenges/dynamic-programming-classics-the-longest-common-subsequence/problem)|Medium|[View](Algorithms/Dynamic%20Programming/The%20Longest%20Common%20Subsequence/solution.cpp)|[View](/Algorithms/Dynamic%20Programming/The%20Longest%20Common%20Subsequence/solution.java)|[View](/Algorithms/Dynamic%20Programming/The%20Longest%20Common%20Subsequence/solution.py)| +||[Closest Numbers](https://www.hackerrank.com/challenges/closest-numbers/problem)|Easy|[View](Algorithms/Sorting/Closest%20Numbers/solution.cpp)|[View](Algorithms/Sorting/Closest%20Numbers/solution.java)|[View](Algorithms/Sorting/Closest%20Numbers/solution.py)| +||[CamelCase](https://www.hackerrank.com/challenges/camelcase/problem)|Easy|[View](Algorithms/Strings/CamelCase/solution.cpp)|[View](Algorithms/Strings/CamelCase/solution.java)|[View](Algorithms/Strings/CamelCase/solution.py)| +||[Lonely Integer](https://www.hackerrank.com/challenges/lonely-integer/problem)|Easy|[View](Algorithms/Bit%20Manipulation/Lonely%20Integer/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Lonely%20Integer/solution.java)|[View](Algorithms/Bit%20Manipulation/Lonely%20Integer/solution.py)| +||[Sum vs XOR](https://www.hackerrank.com/challenges/sum-vs-xor/problem)|Easy|[View](Algorithms/Bit%20Manipulation/Sum%20vs%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Sum%20vs%20XOR/solution.java)|[View](Algorithms/Bit%20Manipulation/Sum%20vs%20XOR/solution.py)| +||[Maximizing XOR](https://www.hackerrank.com/challenges/maximizing-xor/problem)|Easy|[View](Algorithms/Bit%20Manipulation/Maximizing%20XOR/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Maximizing%20XOR/solution.java)|[View](Algorithms/Bit%20Manipulation/Maximizing%20XOR/solution.py)| +||[Birthday Cake Candles](https://www.hackerrank.com/challenges/birthday-cake-candles/problem)|Easy|[View](Algorithms/Warmup/Birthday%20Cake%20Candles/solution.cpp)|[View](Algorithms/Warmup/Birthday%20Cake%20Candles/solution.java)|[View](Algorithms/Warmup/Birthday%20Cake%20Candles/solution.py)| +||[Sub-array Division](https://www.hackerrank.com/challenges/the-birthday-bar/problem)|Easy|[View](Algorithms/Implementation/Sub-array%20Division/solution.cpp)|[View](Algorithms/Implementation/Sub-array%20Division/solution.java)|[View](Algorithms/Implementation/Sub-array%20Division/solution.py)| +||[Bill Division](https://www.hackerrank.com/challenges/bon-appetit/problem)|Easy|[View](Algorithms/Implementation/Bill%20Division/solution.cpp)|[View](Algorithms/Implementation/Bill%20Division/solution.java)|[View](Algorithms/Implementation/Bill%20Division/solution.py)| +||[Marc's Cakewalk](https://www.hackerrank.com/challenges/marcs-cakewalk/problem)|Easy|[View](Algorithms/Greedy/Marc's%20Cakewalk/solution.cpp)|[View](Algorithms/Greedy/Marc's%20Cakewalk/solution.java)|[View](Algorithms/Greedy/Marc's%20Cakewalk/solution.py)| +||[Flipping Bits](https://www.hackerrank.com/challenges/flipping-bits/problem)|Easy|[View](/Algorithms/Bit%20Manipulation/Flipping%20Bits/solution.cpp)|[View](Algorithms/Bit%20Manipulation/Flipping%20Bits/solution.java)|[View](Algorithms/Bit%20Manipulation/Flipping%20Bits/solution.py)| +||[The Longest Common Subsequence](https://www.hackerrank.com/challenges/dynamic-programming-classics-the-longest-common-subsequence/problem)|Medium|[View](Algorithms/Dynamic%20Programming/The%20Longest%20Common%20Subsequence/solution.cpp)|[View](Algorithms/Dynamic%20Programming/The%20Longest%20Common%20Subsequence/solution.java)|[View](Algorithms/Dynamic%20Programming/The%20Longest%20Common%20Subsequence/solution.py)| ||[Halloween Sale](https://www.hackerrank.com/challenges/halloween-sale/problem)|Easy|[View](Algorithms/Implementation/Halloween%20Sale/solution.cpp)|[View](Algorithms/Implementation/Halloween%20Sale/solution.java)|[View](Algorithms/Implementation/Halloween%20Sale/solution.py)| ||[Chocolate Feast](https://www.hackerrank.com/challenges/chocolate-feast/problem)|Easy|[View](Algorithms/Implementation/Chocolate%20Feast/solution.cpp)|[View](Algorithms/Implementation/Chocolate%20Feast/solution.java)|[View](Algorithms/Implementation/Chocolate%20Feast/solution.py)| -||[Save the Prisoner](https://www.hackerrank.com/challenges/save-the-prisoner/problem)|Easy|[View](/Algorithms/Implementation/Save%20The%20Prisoner/solution.cpp)|[View](/Algorithms/Implementation/Save%20The%20Prisoner/solution.java)|[View](/Algorithms/Implementation/Save%20The%20Prisoner/solution.py)| -||[Library Fine](https://www.hackerrank.com/challenges/library-fine/problem)|Easy|[View](Algorithms/Implementation/Library%20Fine/solution.cpp)|[View](Algorithms/Implementation/Library%20Fine/solution.java)|[View](/Algorithms/Library%20Fine/solution.py)| -||[Non-Divisible Subset](https://www.hackerrank.com/challenges/non-divisible-subset/problem)|Medium|[view](/Algorithms/Implementation/Non-Divisible%20Subset/solution.cpp)|[View](/Algorithms/Implementation/Non-Divisible%20Subset/solution.java)|[View](/Algorithms/Implementation/Non-Divisible%20Subset/solution.py)| -||[Candies](https://www.hackerrank.com/challenges/candies/problem)|Medium||[View](/Algorithms/Greedy/Candies/solution.java)||[View](/Algorithms/Greedy/Candies/solution.py)| +||[Save the Prisoner!](https://www.hackerrank.com/challenges/save-the-prisoner/problem)|Easy|[View](Algorithms/Implementation/Save%20the%20Prisoner!/solution.cpp)|[View](Algorithms/Implementation/Save%20the%20Prisoner!/solution.java)|[View](Algorithms/Implementation/Save%20the%20Prisoner!/solution.py)| +||[Library Fine](https://www.hackerrank.com/challenges/library-fine/problem)|Easy|[View](Algorithms/Implementation/Library%20Fine/solution.cpp)|[View](Algorithms/Implementation/Library%20Fine/solution.java)|[View](Algorithms/Implementation/Library%20Fine/solution.py)| +||[Non-Divisible Subset](https://www.hackerrank.com/challenges/non-divisible-subset/problem)|Medium|[view](Algorithms/Implementation/Non-Divisible%20Subset/solution.cpp)|[View](Algorithms/Implementation/Non-Divisible%20Subset/solution.java)|[View](Algorithms/Implementation/Non-Divisible%20Subset/solution.py)| +||[Candies](https://www.hackerrank.com/challenges/candies/problem)|Medium||[View](Algorithms/Greedy/Candies/solution.java)|[View](Algorithms/Greedy/Candies/solution.py)| ||[3-D Surface Area](https://www.hackerrank.com/challenges/3d-surface-area/problem)|Medium|[View](Algorithms/Implementation/3-D%20Surface%20Area/solution.cpp)|[View](Algorithms/Implementation/3-D%20Surface%20Area/solution.java)|[View](Algorithms/Implementation/3-D%20Surface%20Area/solution.py)| -||[Minimum Average Waiting Time](https://www.hackerrank.com/challenges/minimum-average-waiting-time/problem)|Hard|||[View](/Heap/Minimum%20Average%20Waiting%20Time/solution.py)| -||[Viral Advertising](https://www.hackerrank.com/challenges/strange-advertising/problem)|Easy|[View](/Algorithms/Implementation/Viral%20Advertising/solution.cpp)|[View](Algorithms/Implementation/Viral%20Advertising/solution.java)|[View](/Algorithms/Implementation/Viral%20Advertising/solution.py)| -||[Minimum Loss](https://www.hackerrank.com/challenges/minimum-loss/problem)|Medium|[View](/Algorithms/Minimum%20Loss/solution.cpp)|[View](/Algorithms/Minimum%20Loss/solution.java)|[View](/Algorithms/Minimum%20Loss/solution.py)| +||[Viral Advertising](https://www.hackerrank.com/challenges/strange-advertising/problem)|Easy|[View](Algorithms/Implementation/Viral%20Advertising/solution.cpp)|[View](Algorithms/Implementation/Viral%20Advertising/solution.java)|[View](Algorithms/Implementation/Viral%20Advertising/solution.py)| +||[Minimum Loss](https://www.hackerrank.com/challenges/minimum-loss/problem)|Medium|[View](Algorithms/Search/Minimum%20Loss/solution.cpp)|[View](Algorithms/Search/Minimum%20Loss/solution.java)|[View](Algorithms/Search/Minimum%20Loss/solution.py)| ||[Minimum Absolute Difference in an Array](https://www.hackerrank.com/challenges/minimum-absolute-difference-in-an-array/problem)|Medium|[View](Algorithms/Greedy/Minimum%20Absolute%20Difference%20in%20an%20Array/solution.cpp)|[View](Algorithms/Greedy/Minimum%20Absolute%20Difference%20in%20an%20Array/solution.java)|[View](Algorithms/Greedy/Minimum%20Absolute%20Difference%20in%20an%20Array/solution.py)| -||[Beautiful Pairs](https://www.hackerrank.com/challenges/beautiful-pairs/problem)|Easy|[View](/Algorithms/Greedy/Beautiful%20Pairs/solution.cpp)|[View](/Algorithms/Greedy/Beautiful%20Pairs/solution.java)|[View](/Algorithms/Greedy/Beautiful%20Pairs/solution.py)| -||[Greedy Florist](https://www.hackerrank.com/challenges/greedy-florist/problem)|Medium|[View](/Algorithms/Greedy/Greedy%20Florist/solution.cpp)|[View](/Algorithms/Greedy/Greedy%20Florist/solution.java)|[View](/Algorithms/Greedy/Greedy%20Florist/solution.py)| -||[Priyanka and Toys](https://www.hackerrank.com/challenges/priyanka-and-toys/problem)|Easy|[View](Algorithms/Greedy/Priyanka%20and%20Toys/solution.cpp)|[View](/Algorithms/Greedy/Priyanka%20and%20Toys/solution.java)|[View](/Algorithms/Greedy/Priyanka%20and%20Toys/solution.py)| -||[Compare the Triplets](https://www.hackerrank.com/challenges/compare-the-triplets/problem)|Easy|[View](/Algorithms/Warmup/Compare%20the%20Triplets/solution.cpp)|[View](/Algorithms/Warmup/Compare%20the%20Triplets/solution.java)|[View](/Algorithms/Warmup/Compare%20the%20Triplets/solution.py)| -||[ACM ICPC Team](https://www.hackerrank.com/challenges/acm-icpc-team/problem)|Easy|[View](/Algorithms/Implementation/ACM%20ICPC%20Team/solution.cpp)|[View](/Algorithms/Implementation/ACM%20ICPC%20Team/solution.java)|| -||[Beautiful Days at the Movies](https://www.hackerrank.com/challenges/beautiful-days-at-the-movies/problem)|Easy|[View](/Algorithms/Implementation/Beautiful%20Days%20at%20the%20Movies/solution.cpp)|[View](Algorithms/Implementation/Beautiful%20Days%20at%20the%20Movies/solution.java)|[View](/Algorithms/Implementation/Beautiful%20Days%20at%20the%20Movies/solution.py)| -||[Fibonacci Modified](https://www.hackerrank.com/challenges/fibonacci-modified/problem)|Medium|[View](/Algorithms/Dynamic%20Programming/Fibonacci%20Modified/solution.cpp)|[View](/Algorithms/Dynamic%20Programming/Fibonacci%20Modified/solution.java)|[View](/Algorithms/Dynamic%20Programming/Fibonacci%20Modified/solution.py)| -||[Knapsack](https://www.hackerrank.com/challenges/unbounded-knapsack/problem)|Medium|[View](/Algorithms/Dynamic%20Programming/Knapsack/solution.cpp)|[View](/Algorithms/Dynamic%20Programming/Knapsack/solution.java)|[View](/Algorithms/Dynamic%20Programming/Knapsack/solution.py)| -||[The Bomberman Game](https://www.hackerrank.com/challenges/bomber-man/problem)|Medium|[View](/Algorithms/Implementation/The%20Bomberman%20Game/solution.cpp)|[View](/Algorithms/Implementation/The%20Bomberman%20Game/solution.java)|[View](/Algorithms/Implementation/The%20Bomberman%20Game/solution.py)| -||[Organizing Containers of Balls](https://www.hackerrank.com/challenges/organizing-containers-of-balls/problem)|Easy|[View](Algorithms/Organizing%20Containers%20of%20Balls/solution.cpp)|[View](Algorithms/Organizing%20Containers%20of%20Balls/solution.java)|[View](/Algorithms/Organizing%20Containers%20of%20Balls/solution.py)| -||[String Construction](https://www.hackerrank.com/challenges/string-construction/problem)|Easy||[View](/Algorithms/Strings/String%20Construction/solution.java)|[View](/Algorithms/Strings/String%20Construction/solution.py)| -||[Highest Value Palindrome](https://www.hackerrank.com/challenges/richie-rich/problem)|Medium|||[View](/Algorithms/Strings/Highest%20Value%20Palindrome/solution.java)|[View](/Algorithms/Strings/Highest%20Value%20Palindrome/solution.py)| -||[Lily's Homework](https://www.hackerrank.com/challenges/lilys-homework/problem)|Medium||[View](/Algorithms/Sorting/Lily's%20Homework/solution.java)|[View](/Algorithms/Sorting/Lily's%20Homework/solution.py)| +||[Beautiful Pairs](https://www.hackerrank.com/challenges/beautiful-pairs/problem)|Easy|[View](Algorithms/Greedy/Beautiful%20Pairs/solution.cpp)|[View](Algorithms/Greedy/Beautiful%20Pairs/solution.java)|[View](Algorithms/Greedy/Beautiful%20Pairs/solution.py)| +||[Greedy Florist](https://www.hackerrank.com/challenges/greedy-florist/problem)|Medium|[View](Algorithms/Greedy/Greedy%20Florist/solution.cpp)|[View](Algorithms/Greedy/Greedy%20Florist/solution.java)|[View](Algorithms/Greedy/Greedy%20Florist/solution.py)| +||[Priyanka and Toys](https://www.hackerrank.com/challenges/priyanka-and-toys/problem)|Easy|[View](Algorithms/Greedy/Priyanka%20and%20Toys/solution.cpp)|[View](Algorithms/Greedy/Priyanka%20and%20Toys/solution.java)|[View](Algorithms/Greedy/Priyanka%20and%20Toys/solution.py)| +||[Compare the Triplets](https://www.hackerrank.com/challenges/compare-the-triplets/problem)|Easy|[View](Algorithms/Warmup/Compare%20the%20Triplets/solution.cpp)|[View](Algorithms/Warmup/Compare%20the%20Triplets/solution.java)|[View](Algorithms/Warmup/Compare%20the%20Triplets/solution.py)| +||[ACM ICPC Team](https://www.hackerrank.com/challenges/acm-icpc-team/problem)|Easy|[View](Algorithms/Implementation/ACM%20ICPC%20Team/solution.cpp)|[View](Algorithms/Implementation/ACM%20ICPC%20Team/solution.java)|| +||[Beautiful Days at the Movies](https://www.hackerrank.com/challenges/beautiful-days-at-the-movies/problem)|Easy|[View](Algorithms/Implementation/Beautiful%20Days%20at%20the%20Movies/solution.cpp)|[View](Algorithms/Implementation/Beautiful%20Days%20at%20the%20Movies/solution.java)|[View](Algorithms/Implementation/Beautiful%20Days%20at%20the%20Movies/solution.py)| +||[Fibonacci Modified](https://www.hackerrank.com/challenges/fibonacci-modified/problem)|Medium|[View](Algorithms/Dynamic%20Programming/Fibonacci%20Modified/solution.cpp)|[View](Algorithms/Dynamic%20Programming/Fibonacci%20Modified/solution.java)|[View](Algorithms/Dynamic%20Programming/Fibonacci%20Modified/solution.py)| +||[Knapsack](https://www.hackerrank.com/challenges/unbounded-knapsack/problem)|Medium|[View](Algorithms/Dynamic%20Programming/Knapsack/solution.cpp)|[View](Algorithms/Dynamic%20Programming/Knapsack/solution.java)|[View](Algorithms/Dynamic%20Programming/Knapsack/solution.py)| +||[The Bomberman Game](https://www.hackerrank.com/challenges/bomber-man/problem)|Medium|[View](Algorithms/Implementation/The%20Bomberman%20Game/solution.cpp)|[View](Algorithms/Implementation/The%20Bomberman%20Game/solution.java)|[View](Algorithms/Implementation/The%20Bomberman%20Game/solution.py)| +||[Organizing Containers of Balls](https://www.hackerrank.com/challenges/organizing-containers-of-balls/problem)|Easy|[View](Algorithms/Implementation/Organizing%20Containers%20of%20Balls/solution.cpp)|[View](Algorithms/Implementation/Organizing%20Containers%20of%20Balls/solution.java)|[View](Algorithms/Implementation/Organizing%20Containers%20of%20Balls/solution.py)| +||[String Construction](https://www.hackerrank.com/challenges/string-construction/problem)|Easy||[View](Algorithms/Strings/String%20Construction/solution.java)|[View](Algorithms/Strings/String%20Construction/solution.py)| +||[Highest Value Palindrome](https://www.hackerrank.com/challenges/richie-rich/problem)|Medium||[View](Algorithms/Strings/Highest%20Value%20Palindrome/solution.java)|[View](Algorithms/Strings/Highest%20Value%20Palindrome/solution.py)| +||[Lily's Homework](https://www.hackerrank.com/challenges/lilys-homework/problem)|Medium||[View](Algorithms/Sorting/Lily's%20Homework/solution.java)|[View](Algorithms/Sorting/Lily's%20Homework/solution.py)| | Contest Problems | ||[Squares of a Sorted Array](https://www.hackerrank.com/contests/coding-gym-mo0419/challenges/squares-of-a-sorted-array)|Medium|[View](/Contest%20Problems/Squares%20of%20a%20Sorted%20Array/solution.cpp)|[View](/Contest%20Problems/Squares%20of%20a%20Sorted%20Array/solution.java)|[View](/Contest%20Problems/Squares%20of%20a%20Sorted%20Array/solution.py)| | Disjoint Sets |