HackerRank Solutions

Over the course of the next few (actually many) days, I will be posting the solutions to previous Hacker Rank challenges. The page is a good start for people to solve these problems as the time constraints are rather forgiving. I have most solutions in C++, but I will be trying to post them in Python. The language is more readable. Recently I started adding Rust code as well.

My public HackerRank profile here.

I have solutions to all listed solutions. If the solution is not listed, I have not solved it yet. If there is no link, it means that I did not parse the algorithm to a readable format yet.

Algorithms

Warmup and Implementation

Arrays and Sorting

Search

  • [Easy] Encryption
  • [Easy] Ice Cream Parlor
  • [Easy] Sherlock and Array
  • [Moderate] Beautiful Quadruples
  • [Moderate] Circle City
  • [Moderate] Connected Cell in a Grid
  • [Moderate] Cut the tree
  • [Moderate] Count Luck
  • [Moderate] Find Maximum Index Product
  • [Moderate] Gena Playing Hanoi
  • [Moderate] Missing Numbers
  • [Moderate] Number List
  • [Moderate] Pairs
  • [Moderate] Short Palindrome
  • [Moderate] The Grid Search
  • [Difficult] Absolute Element Sums
  • [Difficult] Bike Racers
  • [Difficult] Journey Scheduling
  • [Difficult] King Richard’s Knights
  • [Difficult] Maximum Subarray Sum
  • [Difficult] Median Updates
  • [Difficult] Playing with numbers
  • [Advanced] Similar Pair
  • [Advanced] Task Scheduling

Dynamic Programming

  • [Easy] The Maximum Subarray
  • [Moderate] Bricks Game
  • [Moderate] Candies
  • [Moderate] Fibonacci Modified
  • [Moderate] Hexagonal Grid
  • [Moderate] Knapsack
  • [Moderate] Red John is Back
  • [Moderate] Stock Maximize
  • [Moderate] Substring Diff
  • [Moderate] The Coin Change Problem
  • [Moderate] The Longest Common Subsequence
  • [Moderate] XOR and SUM
  • [Advanced] The Longest Increasing Subsequence
  • [Expert] Lucky Numbers
  • …..

Strings

  • [Easy] Alternating Characters
  • [Easy] Anagram
  • [Easy] Beautiful Binary String
  • [Easy] Caesar Cipher
  • [Easy] Camel Case
  • [Easy] Funny String
  • [Easy] Game of Thrones – I
  • [Easy] Gem Stones
  • [Easy] HackerRank is a String!
  • [Easy] Make It Anagram
  • [Easy] Mars Exploration
  • [Easy] Palindrome Index
  • [Easy] Pangrams
  • [Easy] Richie Rich
  • [Easy] Separate the Numbers
  • [Easy] String Construction
  • [Easy] Strong Password
  • [Easy] Super Reduced String
  • [Easy] The Love-Letter Mystery
  • [Easy] Two Characters
  • [Easy] Two Strings
  • [Easy] Weighted Uniform Strings
  • [Moderate] Bear and Steady Gene
  • [Moderate] Common Child
  • [Moderate] Highest Value Palindrome
  • [Moderate] Sherlock and Anagrams
  • [Moderate] Sherlock and The Valid String
  • [Moderate] Yet Another KPM Problem
  • [Difficult] Ashton and String
  • [Difficult] Build a Palindrome
  • [Difficult] Build a String
  • [Difficult] Circular Palindromes
  • [Difficult] Common Child
  • [Difficult] Count Strings
  • [Difficult] Find Strings
  • [Difficult] Gridland Provinces
  • [Difficult] Letter Islands
  • [Difficult] Morgan and a String
  • [Difficult] Palindromic Border
  • [Difficult] Pseudo-Isomorphic Substrings
  • [Difficult] Sherlock and Valid String
  • [Difficult] Save Humanity
  • [Difficult] String Function Calculation
  • [Difficult] String Similarity
  • [Difficult] Two Strings Game
  • [Difficult] Two Two
  • ….

Bit Manipulation

  • [Easy] Cipher
  • [Easy] Flipping Bits
  • [Easy] Lonely Integer
  • [Moderate] A or B
  • [Moderate] AND Product
  • [Moderate] Cipher
  • [Moderate] Counter Game
  • [Moderate] Sansa and XOR
  • [Moderate] What’s Next?
  • [Moderate] Xor-sequence
  • [Difficult] 2’s Complement
  • [Difficult] Changing Bits
  • [Difficult] Hamming Distance
  • [Difficult] String Transmission
  • [Difficult] Manipulative Numbers
  • [Difficult] Stone Game
  • [Difficult] String Transmission
  • [Difficult] XOR Key
  • [Difficult] XOR Subsequences
  • [Difficult] Xoring Ninja

Mathematics

Combinatorics

  • [Easy] A Chocolate Fiesta
  • [Easy] Building a List
  • [Easy] Connecting Towns
  • [Easy] Handshake
  • [Easy] Minimum Draws
  • [Easy] Merge List
  • [Easy] Picking Cards

Data Structures

Stacks

Queues