Home

Awesome

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

ProblemDifficultySolution Link
Solve Me FirstEasyJava Python
Simple Array SumEasyJava
Compare The TripletsEasyJava
A very Big SumEasyJava
Diagonal DifferenceEasyJava Python
Plus MinusEasyJava
StaircaseEasyJava
Mini-Max SumEasyJava
Birthday Cake CandlesEasyJava
Time ConversionEasyJava

Implementation problems-solved

ProblemDifficultySolution Link
Grading StudentsEasyJava
Apple and OrangeEasyJava
KangarooEasyJava
Between Two SetsEasyJava
Breaking The RecordsEasyJava
Birthday ChocolateEasyJava
Divisible Sum PairsEasyJava
Migratory BirdsEasyJava
Day of the ProgrammerEasyJava
Bon AppétitEasyJava
Sock MerchantEasyJava
Drawing BookEasyJava
Counting ValleysEasyJava
Electronics ShopEasyJava
Cats and a MouseEasyJava
Forming a Magic SquareMediumJava
Picking NumbersEasyJava
Climbing The LeaderboardMediumJava
The Hurdle RaceEasyJava
Designer PDF ViewerEasyJava
Utopian TreeEasyJava
Angry ProfessorEasyJava
Beautiful Days at the moviesEasyJava
Viral AdvertisingEasyJava
Save The PrisonerEasyJava
Circular Array RotationEasyJava
Sequence EquationEasyJava
Jumping On the Clouds RevisitedEasyJava
Find DigitsEasyJava
Extra Long factorialsMediumJava Python
Append and DeleteEasyJava
Sherlock and SquaresEasyJava
Library FineEasyJava
Cut the SticksEasyJava
Non-Divisible SubsetMediumJava
Repeated StringEasyJava
Jumping on The CloudsEasyJava
Equalize The ArrayEasyJava
Queen's Attack IIMediumJava
ACM ICPC TeamEasyJava
Taum and B'DdayEasyJava
Organizing Containers of BallsMediumJava
EncryptionMediumJava
Modified Kaprekar numbersEasyJava
Beautiful TripletsEasyJava
Minimum DistancesEasyJava
Halloween SalesEasyJava
The Time in WordsMediumJava
Chocolate FeastEasyJava
Service LaneEasyJava
Lisa's WorkbookEasyJava
Flatland Space StationsEasyJava
Fair RationsEasyJava
Cavity MapEasyJava
Manasa and StonesEasyJava
The Grid SearchMediumJava
Happy LadybugsEasyJava
Strange CounterEasyJava
3D Surface AreaMediumJava
Absolute PermutationsMediumJava
The Bomberman GameMediumJava
Emma's SupercomputerMediumC++
Larry's ArrayMediumJava
Almost SortedMediumJava
Matrix Layer RotationHardJava
Bigger is GreaterMediumJava

Strings problems-solved

ProblemDifficultySolution Link
Strong PasswordEasyJava
Super Reduced StringEasyJava
CamelCaseEasyJava
Two CharactersEasyJava
Caeser CipherEasyJava
Mars ExplorationEasyJava
HackerRank In a String!EasyJava
PangramsEasyJava
Weighted Uniform StringsEasyJava
Separate The NumbersEasyJava
Funny StringEasyJava
GemstonesEasyJava
Alternating CharactersEasyJava
Beautiful Binary StringEasyJava
The Love-Letter MysetryEasyJava
Palindromic IndexEasyJava
AnagramEasyJava
Making AnagramsEasyJava
Game of Thrones - IEasyJava
Two StringsEasyJava
String ConstructionEasyJava
Highest Value PalindromeMediumJava
Sherlock and The Valid StringMediumJava
Maximum PalindromesMediumJava
Sherlock and AnagramsMediumJava
Common ChildMediumJava
Bear and Steady GeneMediumJava
Determining DNA HealthHard
Morgan and StringExpert
Count StringsHard
String Function CalculationAdvanced
Build a PalindromeAdvanced
Build a StringHard
Gridland ProvincesHard
Cards PermutationsExpert
Ashton and StringAdvanced
String SimilarityExpert
Super Functional StringsAdvanced
Circular PalindromesAdvanced
Similar StringsAdvanced
Save HumanityExpert
Find StringsExpert
Palindromic BorderExpert
Two TwoAdvanced
Two String GameExpert
Letter IslandsExpert
Pseudo-Isomorphic SubstringsExpert
How many Substrings?Expert

Sorting problems-solved

ProblemDifficultySolution Link
Insertion Sort - Part 1Easy
Insertion Sort - Part 2Easy
Running Time of AlgorithmsEasy
Quicksort 1 - PartitionEasy
Fraudulent Activity NotificationsMedium
Lily's HomeworkMedium
Insertion Sort Advanced AnalysisAdvanced

Search problems-solved

ProblemDifficultySolution Link
Missing NumbersEasy
Hackerland Radio TransmittersMedium
Gridland MetroMedium
KnightL On ChessBoardMedium
Minimum LossMedium
Short PalindromeMedium
Count LuckMedium
Cut The TreeMedium
Gena Playing HanoiMedium
Beautiful QuadruplesMedium
Red Knight's Shortest PathMedium
Maximizing Mission PointsHard
Making CandiesHard
Bike RacersHard
Task SchedulingHard
Similar PairHard
Absolute Element SumHard
Almost Integer Rock GardenHard
Sorted SubsegmentsHard
Distant PairsHard
Knight Richard's KnightsHard

Graph Theory problems-solved

ProblemDifficultySolution Link
Journey To The MoonMedium
Synchronous ShoppingMedium
Breadth First Search: Shortest ReachMedium
Kruskal (MST): Really Special SubtreeMedium
Even TreeMedium
Snakes and Ladders: The Quickest Way UpMedium
The Story Of A TreeMedium
Prim's (MST): Special SubtreeMedium
CliqueMedium
Minimum Penalty PathMedium
Jack Goes To RaptureMedium
Crab GraphsMedium
Jeanie's RouteMedium
Roads in HackerLandMedium
Rust & MurdererMedium
Frog And MazeHard
Subset ComponentHard
Dijkstra: Shortest Reach 2Hard
Toll Cost DigitsHard
Real Estate BrokerHard
Demanding MoneyHard
The Value Of FriendshipHard
Coprime PathsExpert
Minimum MST GraphExpert
Bread OrnamentsAdvanced
Floyd: City Of Blinding LightsHard
Kingdom ConnectivityHard
Computer GameHard
Problem SolvingHard
Journey SchedulingHard
Recording EpisodesHard
Repair RoadsHard
Kth AncestorHard
ByteLandian ToursHard
Find The PathHard
Savita & FriendsHard
LiarsAdvanced
Jumping RocksAdvanced
Tripartite MatchingHard
Tree FlowHard
DAG QueriesExpert
Favorite SequenceAdvanced
Jogging CatsAdvanced
Quadrant QueriesAdvanced
Hacker CountryHard
HackerXHard
HuarongdaoExpert
Training The ArmyHard
Jim and His LAN PartyHard
Travel in HackerLandHard
Alex vs FedorExpert
Vertical PathsExpert
DriveExpert
Travelling Salesman In A GridExpert
Road NetworkExpert
Going To The OfficeExpert
Tree SplittingAdvanced
TicketExpert
DFS EdgesExpert
Diameter MinimizationExpert
AirportsExpert
Definite Random WalksExpert

Greedy problems-solved

ProblemDifficultySolution Link
Minimum Absolute Difference In ArrayEasy
Marc's CakewalkEasy
Grid ChallengeEasy
Luck BalanceEasy
Maximum Perimeter TriangleEasy
Beautiful PairsEasy
Sherlock and The BeastEasy
Priyanka and ToysEasy
Largest PermutationEasy
Mark and ToysEasy
Jim and The OrdersEasy
Permuting Two ArraysEasy
CandiesMedium
Greedy FloristMedium
Max MinMedium
Cloudy DayMedium
Cutting BoardsHard
Chief HopperHard
Sherlock and MinMaxHard
Accessory CollectionHard
Fighting PitsHard
Reverse Shuffle MergeAdvanced
Team FormationAdvanced

Dynamic Programming problems-solved

ProblemDifficultySolution Link
The Coin Change ProblemMedium
EqualMedium
Sherlock and CostMedium
Construct The ArrayMedium
Kingdom DivisionMedium
Sam and SubstringsMedium
Fibonacci ModifiedMedium
AbbreviationMedium
Prime XORMedium
Fair CutMedium
The Maximum SubarrayMedium
Prime Digit SumMedium
HackerRank CityMedium
Summing PiecesMedium
Mr K MarshMedium
Substring DiffMedium
Xor and SumMedium
Lego BlocksMedium
Stock MaximizeMedium
Two RobotsMedium
Cut TreeMedium
Wet Shark and Two SubsequencesMedium
Nikita and the GameMedium
Mandragora ForestMedium
Red John is BackMedium
LCS ReturnsMedium
Grid WalkingMedium
KnapsackMedium
Bricks GameMedium
Coin On The TableMedium
The Longest Common SubsequenceMedium
Play With WordsMedium
Counting Special Sub-CubesMedium
Interval SelectionMedium
The Indian JobMedium
Travel Around The WorldMedium
Candles CountingMedium
Swap PermutationMedium
Extremum PermutationsMedium
Decibinary NumbersHard
Angry Children 2Hard
Sherlock's Array Merging ProblemHard
Brick TillingHard
Alien LanguageHard
Tara's Beautiful PermutationsHard
Choosing White BallsHard
Matrix LandHard
Black and White TreeHard
String ReductionHard
Far VerticesHard
Superman Celebrates DiwaliHard
Hexagonal GridHard
Queens On BoardHard
Turn of The LightsHard
Animal TransportHard
A Super HeroHard
Clues On Binary PathHard
Road MaintenanceHard
Beautiful StringsHard
Covering The StainsHard
GCD MatrixHard
New Year PresentHard
Longest Palindromic SubsequenceHard
Square SubsequencesHard
Police OperationHard
Zurikela's GraphHard
Longest Mod PathHard
P-SequencesHard
Oil WellHard
The BlacklistHard
Ones and TwosHard
Unique Divide and ConquerAdvanced
Dortmund DilemmaAdvanced
Super Kth LISAdvanced
Points In PlaneAdvanced
Fairy ChessAdvanced
MiningAdvanced
RequirementAdvanced
RobotAdvanced
Unfair GameAdvanced
Modify The SequenceAdvanced
Vim WarAdvanced
Best SpotAdvanced
Hyper StringsAdvanced
Tree PruningAdvanced
Dorsey ThiefAdvanced
Find The SeedAdvanced
BillboardsAdvanced
Shashank and Palindromic StringsAdvanced
The Longest Increasing SubsequenceAdvanced
Counting The WaysExpert
Hard Disk DrivesExpert
Separate The ChocolateExpert
King and Four SonsExpert
Divisible NumbersExpert
Counting Road NetworksExpert
Count ScorecardsExpert
Suffix RotationExpert
Lucky NumbersExpert

Constructive Algorithms problems-solved

ProblemDifficultySolution Link
Lena SortMedium
Flipping The MatrixMedium
Gaming ArrayMedium
New Year ChaosMedium
BonetrousleMedium
Yet Another KMP ProblemHard
Beautiful 3 SetHard
Inverse RMQHard
Lovely TripletsAdvanced
Array ConstructionAdvanced
Two SubarraysExpert

Bit Manipulation problems-solved

ProblemDifficultySolution Link
Lonely IntegerEasy
Maximizing XOREasy
Sum vs XOREasy
Flipping BitsEasy
Counter GameMedium
Xor-sequenceMedium
The Great XORMedium
Yet Another Minimax ProblemMedium
Sansa and XORMedium
AND ProductMedium
Winning Lottery TicketMedium
CipherMedium
What's Next?Medium
A or BMedium
Xoring NinjaHard
XOR MatrixHard
String TransmissionHard
Manipulative NumbersHard
Stone GameHard
Mixing ProteinsHard
Maximizing The FunctionHard
2's ComplementAdvanced
Changing BitsAdvanced
XOR KeyAdvanced
XOR SubsequencesAdvanced
Iterate ItExpert
Hamming DistanceExpert

Recursion problems-solved

ProblemDifficultySolution Link
The Power SumMedium
Crossword PuzzleMedium
Recursive Digit SumMedium
Simplified Chess EngineMedium
Password CrackerMedium
Stone Division, RevisitedMedium
Arithmetic ExpressionsHard
K FactorizationHard
Bowling PinsHard
Simplified Chess Engine IIHard
Repitive K-SumsAdvanced

Game Theory problems-solved

ProblemDifficultySolution Link
Game Of StonesEasy
Tower BreakerEasy
A Chessboard GameEasy
Introduction To Nim GameEasy
Misère NimEasy
Nimble GameEasy
Poker NimEasy
Alice and Bob's Silly GameMedium
Tower Breakers, Revisited!Medium
Tower Breakers, Again!Medium
Zero Move NimMedium
Chessboard Game AgainMedium
Digits Square BoardMedium
Fun GameMedium
Chocolate In BoxMedium
Kitty and KattyMedium
Powers GameMedium
DeforestationMedium
Bob and BenMedium
Tower Breakers - The Final BattleMedium
Permutation GameMedium
Play on BendersMedium
New Year GameMedium
Vertical RooksMedium
A Stone GameMedium
Stone DivisionHard
Simple GameHard
Move The CoinsHard
Stone PilesHard
Chocolate GameHard
The Prime GameHard
Tastes Like WinningExpert

NP Complete problems-solved

ProblemDifficultySolution Link
Walking The Approximate Longest PathHard
Sam's Puzzle (Approximate)Advanced
Spies, RevisedExpert
TBS ProblemExpert

Debugging problems-solved

ProblemDifficultySolution Link
XOR StringsEasy
Smart NumberEasy
Prime DatesMedium
Minimum OperationsMedium
Zig Zag SequenceMedium