Skip to content

anishLearnsToCode/hackerrank-algorithms

Repository files navigation

HackerRank Algorithms Solutions

problems-solved java python cpp PRs Welcome cp cp

This repository contains solutions to the Algorithms Domain part of HackerRank. The Algorithms Domain Falls under a broader Problem Solving Skill Set in HackerRank which consists of both Data Structures and Algorithms.

The Algorithms Domain is further Divided into the following sub-domains. To Contribute have a look at Contributing.md and happy coding 😀 🐱‍💻.

Sub Domains & Problems (+Solutions) in the Algorithms Domain

⚡ Quick Links: Warm up | Implementation | Strings | Sorting | Search | Graph Theory | Greedy | Dynamic Programming | Constructive Algorithms | Bit Manipulation | Recursion | Game Theory | NP Complete | Debugging

Warmup problems-solved

Problem Difficulty Solution Link
Solve Me First Easy Java Python
Simple Array Sum Easy Java
Compare The Triplets Easy Java
A very Big Sum Easy Java
Diagonal Difference Easy Java Python
Plus Minus Easy Java
Staircase Easy Java
Mini-Max Sum Easy Java
Birthday Cake Candles Easy Java
Time Conversion Easy Java

Implementation problems-solved

Problem Difficulty Solution Link
Grading Students Easy Java
Apple and Orange Easy Java
Kangaroo Easy Java
Between Two Sets Easy Java
Breaking The Records Easy Java
Birthday Chocolate Easy Java
Divisible Sum Pairs Easy Java
Migratory Birds Easy Java
Day of the Programmer Easy Java
Bon Appétit Easy Java
Sock Merchant Easy Java
Drawing Book Easy Java
Counting Valleys Easy Java
Electronics Shop Easy Java
Cats and a Mouse Easy Java
Forming a Magic Square Medium Java
Picking Numbers Easy Java
Climbing The Leaderboard Medium Java
The Hurdle Race Easy Java
Designer PDF Viewer Easy Java
Utopian Tree Easy Java
Angry Professor Easy Java
Beautiful Days at the movies Easy Java
Viral Advertising Easy Java
Save The Prisoner Easy Java
Circular Array Rotation Easy Java
Sequence Equation Easy Java
Jumping On the Clouds Revisited Easy Java
Find Digits Easy Java
Extra Long factorials Medium Java Python
Append and Delete Easy Java
Sherlock and Squares Easy Java
Library Fine Easy Java
Cut the Sticks Easy Java
Non-Divisible Subset Medium Java
Repeated String Easy Java
Jumping on The Clouds Easy Java
Equalize The Array Easy Java
Queen's Attack II Medium Java
ACM ICPC Team Easy Java
Taum and B'Dday Easy Java
Organizing Containers of Balls Medium Java
Encryption Medium Java
Modified Kaprekar numbers Easy Java
Beautiful Triplets Easy Java
Minimum Distances Easy Java
Halloween Sales Easy Java
The Time in Words Medium Java
Chocolate Feast Easy Java
Service Lane Easy Java
Lisa's Workbook Easy Java
Flatland Space Stations Easy Java
Fair Rations Easy Java
Cavity Map Easy Java
Manasa and Stones Easy Java
The Grid Search Medium Java
Happy Ladybugs Easy Java
Strange Counter Easy Java
3D Surface Area Medium Java
Absolute Permutations Medium Java
The Bomberman Game Medium Java
Emma's Supercomputer Medium C++
Larry's Array Medium Java
Almost Sorted Medium Java
Matrix Layer Rotation Hard Java
Bigger is Greater Medium Java

Strings problems-solved

Problem Difficulty Solution Link
Strong Password Easy Java
Super Reduced String Easy Java
CamelCase Easy Java
Two Characters Easy Java
Caeser Cipher Easy Java
Mars Exploration Easy Java
HackerRank In a String! Easy Java
Pangrams Easy Java
Weighted Uniform Strings Easy Java
Separate The Numbers Easy Java
Funny String Easy Java
Gemstones Easy Java
Alternating Characters Easy Java
Beautiful Binary String Easy Java
The Love-Letter Mysetry Easy Java
Palindromic Index Easy Java
Anagram Easy Java
Making Anagrams Easy Java
Game of Thrones - I Easy Java
Two Strings Easy Java
String Construction Easy Java
Highest Value Palindrome Medium Java
Sherlock and The Valid String Medium Java
Maximum Palindromes Medium Java
Sherlock and Anagrams Medium Java
Common Child Medium Java
Bear and Steady Gene Medium Java
Determining DNA Health Hard
Morgan and String Expert
Count Strings Hard
String Function Calculation Advanced
Build a Palindrome Advanced
Build a String Hard
Gridland Provinces Hard
Cards Permutations Expert
Ashton and String Advanced
String Similarity Expert
Super Functional Strings Advanced
Circular Palindromes Advanced
Similar Strings Advanced
Save Humanity Expert
Find Strings Expert
Palindromic Border Expert
Two Two Advanced
Two String Game Expert
Letter Islands Expert
Pseudo-Isomorphic Substrings Expert
How many Substrings? Expert

Sorting problems-solved

Problem Difficulty Solution Link
Insertion Sort - Part 1 Easy
Insertion Sort - Part 2 Easy
Running Time of Algorithms Easy
Quicksort 1 - Partition Easy
Fraudulent Activity Notifications Medium
Lily's Homework Medium
Insertion Sort Advanced Analysis Advanced

Search problems-solved

Problem Difficulty Solution Link
Missing Numbers Easy
Hackerland Radio Transmitters Medium
Gridland Metro Medium
KnightL On ChessBoard Medium
Minimum Loss Medium
Short Palindrome Medium
Count Luck Medium
Cut The Tree Medium
Gena Playing Hanoi Medium
Beautiful Quadruples Medium
Red Knight's Shortest Path Medium
Maximizing Mission Points Hard
Making Candies Hard
Bike Racers Hard
Task Scheduling Hard
Similar Pair Hard
Absolute Element Sum Hard
Almost Integer Rock Garden Hard
Sorted Subsegments Hard
Distant Pairs Hard
Knight Richard's Knights Hard

Graph Theory problems-solved

Problem Difficulty Solution Link
Journey To The Moon Medium
Synchronous Shopping Medium
Breadth First Search: Shortest Reach Medium
Kruskal (MST): Really Special Subtree Medium
Even Tree Medium
Snakes and Ladders: The Quickest Way Up Medium
The Story Of A Tree Medium
Prim's (MST): Special Subtree Medium
Clique Medium
Minimum Penalty Path Medium
Jack Goes To Rapture Medium
Crab Graphs Medium
Jeanie's Route Medium
Roads in HackerLand Medium
Rust & Murderer Medium
Frog And Maze Hard
Subset Component Hard
Dijkstra: Shortest Reach 2 Hard
Toll Cost Digits Hard
Real Estate Broker Hard
Demanding Money Hard
The Value Of Friendship Hard
Coprime Paths Expert
Minimum MST Graph Expert
Bread Ornaments Advanced
Floyd: City Of Blinding Lights Hard
Kingdom Connectivity Hard
Computer Game Hard
Problem Solving Hard
Journey Scheduling Hard
Recording Episodes Hard
Repair Roads Hard
Kth Ancestor Hard
ByteLandian Tours Hard
Find The Path Hard
Savita & Friends Hard
Liars Advanced
Jumping Rocks Advanced
Tripartite Matching Hard
Tree Flow Hard
DAG Queries Expert
Favorite Sequence Advanced
Jogging Cats Advanced
Quadrant Queries Advanced
Hacker Country Hard
HackerX Hard
Huarongdao Expert
Training The Army Hard
Jim and His LAN Party Hard
Travel in HackerLand Hard
Alex vs Fedor Expert
Vertical Paths Expert
Drive Expert
Travelling Salesman In A Grid Expert
Road Network Expert
Going To The Office Expert
Tree Splitting Advanced
Ticket Expert
DFS Edges Expert
Diameter Minimization Expert
Airports Expert
Definite Random Walks Expert

Greedy problems-solved

Problem Difficulty Solution Link
Minimum Absolute Difference In Array Easy
Marc's Cakewalk Easy
Grid Challenge Easy
Luck Balance Easy
Maximum Perimeter Triangle Easy
Beautiful Pairs Easy
Sherlock and The Beast Easy
Priyanka and Toys Easy
Largest Permutation Easy
Mark and Toys Easy
Jim and The Orders Easy
Permuting Two Arrays Easy
Candies Medium
Greedy Florist Medium
Max Min Medium
Cloudy Day Medium
Cutting Boards Hard
Chief Hopper Hard
Sherlock and MinMax Hard
Accessory Collection Hard
Fighting Pits Hard
Reverse Shuffle Merge Advanced
Team Formation Advanced

Dynamic Programming problems-solved

Problem Difficulty Solution Link
The Coin Change Problem Medium
Equal Medium
Sherlock and Cost Medium
Construct The Array Medium
Kingdom Division Medium
Sam and Substrings Medium
Fibonacci Modified Medium
Abbreviation Medium
Prime XOR Medium
Fair Cut Medium
The Maximum Subarray Medium
Prime Digit Sum Medium
HackerRank City Medium
Summing Pieces Medium
Mr K Marsh Medium
Substring Diff Medium
Xor and Sum Medium
Lego Blocks Medium
Stock Maximize Medium
Two Robots Medium
Cut Tree Medium
Wet Shark and Two Subsequences Medium
Nikita and the Game Medium
Mandragora Forest Medium
Red John is Back Medium
LCS Returns Medium
Grid Walking Medium
Knapsack Medium
Bricks Game Medium
Coin On The Table Medium
The Longest Common Subsequence Medium
Play With Words Medium
Counting Special Sub-Cubes Medium
Interval Selection Medium
The Indian Job Medium
Travel Around The World Medium
Candles Counting Medium
Swap Permutation Medium
Extremum Permutations Medium
Decibinary Numbers Hard
Angry Children 2 Hard
Sherlock's Array Merging Problem Hard
Brick Tilling Hard
Alien Language Hard
Tara's Beautiful Permutations Hard
Choosing White Balls Hard
Matrix Land Hard
Black and White Tree Hard
String Reduction Hard
Far Vertices Hard
Superman Celebrates Diwali Hard
Hexagonal Grid Hard
Queens On Board Hard
Turn of The Lights Hard
Animal Transport Hard
A Super Hero Hard
Clues On Binary Path Hard
Road Maintenance Hard
Beautiful Strings Hard
Covering The Stains Hard
GCD Matrix Hard
New Year Present Hard
Longest Palindromic Subsequence Hard
Square Subsequences Hard
Police Operation Hard
Zurikela's Graph Hard
Longest Mod Path Hard
P-Sequences Hard
Oil Well Hard
The Blacklist Hard
Ones and Twos Hard
Unique Divide and Conquer Advanced
Dortmund Dilemma Advanced
Super Kth LIS Advanced
Points In Plane Advanced
Fairy Chess Advanced
Mining Advanced
Requirement Advanced
Robot Advanced
Unfair Game Advanced
Modify The Sequence Advanced
Vim War Advanced
Best Spot Advanced
Hyper Strings Advanced
Tree Pruning Advanced
Dorsey Thief Advanced
Find The Seed Advanced
Billboards Advanced
Shashank and Palindromic Strings Advanced
The Longest Increasing Subsequence Advanced
Counting The Ways Expert
Hard Disk Drives Expert
Separate The Chocolate Expert
King and Four Sons Expert
Divisible Numbers Expert
Counting Road Networks Expert
Count Scorecards Expert
Suffix Rotation Expert
Lucky Numbers Expert

Constructive Algorithms problems-solved

Problem Difficulty Solution Link
Lena Sort Medium
Flipping The Matrix Medium
Gaming Array Medium
New Year Chaos Medium
Bonetrousle Medium
Yet Another KMP Problem Hard
Beautiful 3 Set Hard
Inverse RMQ Hard
Lovely Triplets Advanced
Array Construction Advanced
Two Subarrays Expert

Bit Manipulation problems-solved

Problem Difficulty Solution Link
Lonely Integer Easy
Maximizing XOR Easy
Sum vs XOR Easy
Flipping Bits Easy
Counter Game Medium
Xor-sequence Medium
The Great XOR Medium
Yet Another Minimax Problem Medium
Sansa and XOR Medium
AND Product Medium
Winning Lottery Ticket Medium
Cipher Medium
What's Next? Medium
A or B Medium
Xoring Ninja Hard
XOR Matrix Hard
String Transmission Hard
Manipulative Numbers Hard
Stone Game Hard
Mixing Proteins Hard
Maximizing The Function Hard
2's Complement Advanced
Changing Bits Advanced
XOR Key Advanced
XOR Subsequences Advanced
Iterate It Expert
Hamming Distance Expert

Recursion problems-solved

Problem Difficulty Solution Link
The Power Sum Medium
Crossword Puzzle Medium
Recursive Digit Sum Medium
Simplified Chess Engine Medium
Password Cracker Medium
Stone Division, Revisited Medium
Arithmetic Expressions Hard
K Factorization Hard
Bowling Pins Hard
Simplified Chess Engine II Hard
Repitive K-Sums Advanced

Game Theory problems-solved

Problem Difficulty Solution Link
Game Of Stones Easy
Tower Breaker Easy
A Chessboard Game Easy
Introduction To Nim Game Easy
Misère Nim Easy
Nimble Game Easy
Poker Nim Easy
Alice and Bob's Silly Game Medium
Tower Breakers, Revisited! Medium
Tower Breakers, Again! Medium
Zero Move Nim Medium
Chessboard Game Again Medium
Digits Square Board Medium
Fun Game Medium
Chocolate In Box Medium
Kitty and Katty Medium
Powers Game Medium
Deforestation Medium
Bob and Ben Medium
Tower Breakers - The Final Battle Medium
Permutation Game Medium
Play on Benders Medium
New Year Game Medium
Vertical Rooks Medium
A Stone Game Medium
Stone Division Hard
Simple Game Hard
Move The Coins Hard
Stone Piles Hard
Chocolate Game Hard
The Prime Game Hard
Tastes Like Winning Expert

NP Complete problems-solved

Problem Difficulty Solution Link
Walking The Approximate Longest Path Hard
Sam's Puzzle (Approximate) Advanced
Spies, Revised Expert
TBS Problem Expert

Debugging problems-solved

Problem Difficulty Solution Link
XOR Strings Easy
Smart Number Easy
Prime Dates Medium
Minimum Operations Medium
Zig Zag Sequence Medium