View on GitHub

hackerrank

HackerRank personal solutions

Mathematics

Without mathematics, there’s nothing you can do. Everything around you is mathematics. Everything around you is numbers.

Fundamentals

Name Preview Code Difficulty
Find the Point Given two points P and Q, output the symmetric point of point P about Q. C++ Easy
Maximum Draws Count the minimum Draws Python Easy
Handshake Count the number of Handshakes in a board meeting. Python Easy
Minimum Height Triangle Find the smallest height of a triangle preserving the given constraints. Python Easy
Army Game Find the minimum number of supply packages Luke must drop to supply all of his army bases. Python Easy
Leonardo’s Prime Factors Find the maximum number of prime factors for any number in the inclusive range from 1 to n. Python Easy
Connecting Towns Find the Number of ways to in which one can travel from one town to another. Python Easy
Cutting Paper Squares Determine the number of cuts needed to cut a paper into $1 \times 1$ squares. Python Easy
Summing the N series Sum the N series. Python Medium
Sherlock and Moving Tiles Help Sherlock in identifying the overlapping area. Python Easy
Best Divisor Find the best divisor of the number! Python Easy
Restaurant Help Martha with her interview at Subway Python Easy
Reverse Game Print the final position of the index. Python Easy
Strange Grid Again find the integer in c-th column in r-th row of the grid. Python Easy
Diwali Lights Number of ways to light the room Python Medium
Sherlock and Divisors Help Sherlock in Counting Divisors. Python Easy
Sherlock and Permutations Help Sherlock in counting permutations. Python Hard
Even Odd Query Is the number odd or even? C++ Python Hard
Special Multiple Can you find the least positive integer that is made of only 0s and 9s? - 30 Points C Python Medium
Matrix Tracing How many ways can you trace a given matrix? - 30 Points Python Hard
Die Hard 3 Help Bruce and Samuel save the city by solving their puzzle Python Medium
Halloween party Help Alex give Silvia the maximum number of chocolates Python Easy
Filling Jars Perform the multiple queries on the list. And print average. - 20 Points Python Easy
Is Fibo Find out if a number is a Fibonacci Number or not. Python Medium
K Candy Store In how many ways can you select K candies out of N different types of candies when each of the N candies are infinite in number? Python Medium
Sumar and the Floating Rocks Count the number of integral rocks between Harry and Hermoine Python Easy
Russian Peasant Exponentiation The only correct way to raise numbers in powers. Python Easy
Bus Station Find all suitable bus sizes Python Medium
Most Distant Measure the gap between the two most distant coordinates. Python Easy
Jim and the Jokes Jim is running out of jokes! Help him finding new jokes. Python Medium
Possible Path Help Adam in reaching at aa particular point. Python Easy
Mutual Recurrences Compute terms in a mutual recurrence. C++ Python Medium

Number Theory

Name Preview Code Difficulty
Constructing a Number Construct a number divisible by 3 from the given numbers by reordering their digits. Python Easy
Closest Number What is the closest number? Python Medium
Sherlock and GCD Help Sherlock in finding the subset. Python Easy
Primitive Problem Find the primitive roots of a prime number. Python Easy
Identify Smith Numbers Write a program to check whether a given integer is a Smith number. Python Easy
Euler’s Criterion Detect whether the number is a quadratic residue. Python Easy
Twins How many pairs of twins can you find? Python Medium
Fibonacci Finding (easy) Find some Fibonacci numbers! Python Easy
Little Panda Power Compute A^B mod X Python Hard
Mehta and his Laziness How will Mehta do these calculations? Python Hard
Minimal Distance to Pi Given a range of denominators, find the common fraction that best approximates Pi. Python Hard
Help Mike Help Mike attend the NSA meeting Python Hard
Dancing in Pairs Find out if they can dance in pairs? Python Hard
The Chosen One Given a list of integers, find and print an integer that is a divisor of all but one integer in the list. Python Medium
Power of large numbers How much does Hackerland coach pay to get Cristiano Ronaldo to play for his team? Python Medium
Salary Blues Help manager of HackerX company to normalize salaries. Python Medium
Akhil and GF Help Akhil in impressing his girlfriend Python Hard
Little Ashish’s Huge Donation Help Ashish calculate donations. C++ Hard
Manasa and Factorials Think about number of zeros in k! Python Hard
Number of zero-xor subsets How many subsets with zero xor are here? Python Medium
Breaking Sticks Find the length of the longest sequence of moves. C++ Medium
Cheese and Random Toppings How many ways are there to choose exactly R toppings from N toppings? Python Easy
Easy GCD Find the maximum number less than K such that GCD of all numbers is still more than one! Python Medium
Satisfactory Pairs How many pairs of integers give a solution? C++ Hard
Manasa loves Maths Find out if any permutation of the given number is divisible by 8. Python Medium
Largest Non-Coprime Submatrix Given a matrix find the largest coprime submatrix. C++ Hard
John and GCD list Help John in making a list from GCD list Python Easy
Divisor Exploration II Find the product of a sequence and then calculate the summation of its divisors. Python Hard
Strange numbers How many strange numbers belong to interval [L, R]? Python Hard
Easy math Help Johnny in figuring out the value of Y Python Medium
Equations Find the number of positive integral solutions for an equation. Python Medium
Binomial Coefficients Calculate how many binomial coefficients of n become 0 after modulo by P. Python Medium
Lucy and Flowers Help Lucy’s father with a computation involving flowers C++ Medium
Divisor Exploration 3 Find the value given at the root of a tree constructing by the given rules. C++ Python Hard
Superpowers of 2 Just another numbers problem… Python Advanced
Sherlock Puzzle Help Sherlock get close to his Arch Nemesis, Jim Moriarty. Python Hard
Divisibility of Power Divisibility Test. Python Medium
Devu Vs Police Help Devu escape from police Python Hard
Long Permutation Determine the n^th element of an infinite permutation! Python Hard
Megaprime Numbers Count the number of primes in a given range that consist only of prime digits. Python Medium
Divisor Exploration Find and print the number of divisors for each dataset. Python Hard
Prime Sum Represent a number as sum of primes. Python Medium
nCr Given n and r, in how many ways can r items be chosen from n items? Python Expert
Fibonacci GCD Find gcd for n fibonacci numbers. Python Hard

Combinatorics

Name Preview Code Difficulty
nCr table Help Jim calculating nCr values C++ Python Medium
Coinage Find the number of ways to pay a given amount, given a set of coins with prescribed denominations. Python Medium
Building a List Generate all possible combinations of a string Python Medium
Merge List Help Shashank in merging two list. Python Medium
A Chocolate Fiesta Find the number of even subsets in the given set of numbers. Python Easy
Sherlock and Pairs Count the number of pairs that satisfy a given constraint. Python Medium
Picking Cards How many ways can you pick up all the cards from a table? Python Easy

Algebra

Name Preview Code Difficulty
Combo Meal Find the profit that a fast-food chain earns at each purchase. Python Easy
Stepping Stones Game Can you tell Bob, if he should play Stepping Stones or not ? Python Medium
Shashank and List Help Shashank in Huge calculations. Python Medium
Triangle Numbers Given a triangle numbers where each number is equal to the sum of the three top numbers, find the first even number in a row. Python Medium
Little Gaurav and Sequence Help Gaurav in calculating last digit of a sequence. Python Medium
Easy sum Find the mod sum Python Hard
Difference and Product Answer a question about Difference and Product Python Easy
Pythagorean Triple Find the Pythagorean triple for the given side a. Python Easy
Number Groups Find the sum of consecutive odd number groups. Python Easy
Tell the Average Tell me average of all list value. Python Medium
Wet Shark and 42 Help Wet Shark escape the gods of 42. Python Easy
Sherlock and Square Help Sherlock in finding the total side lengths of squares. Python Hard
Manasa and Sub-sequences Help Manasa in getting candies Python Medium
Simple One Calculate the tan function of a given equation. Python Easy

Geometry

Name Preview Code Difficulty
Points On a Line Given a set of coordinates, determine if they fall in an horizontal or vertical line. Python Easy
Rectangular Game What’s the largest number in the rectangular grid? Python Easy
Sherlock and Counting Help Sherlock count numbers satisfying an inequality. Python Easy
Sherlock and Planes Help Sherlock with points on planes. Python Easy
Circle City Determine whether Roy’s city can be saved or not. Python Medium
Xrange’s Pancakes Determine who needs to be added to the end of the line to restore the pancake to its initial orientation. Python Easy
Baby Step, Giant Step Find the minimum number of steps needed to get to point $(d, 0)$. Python Medium
Points on a Rectangle Determine if a set of points coincides with the edges of a non-degenerate rectangle. Python Easy
A Circle and a Square Draw a circle and a square at specific coordinates within a raster image. C++ Medium

Probability

Name Preview Code Difficulty
Random number generator what’s the probability that x + y is less than C? Python Easy
Sherlock and Probability Help Sherlock in finding the probability. Python Hard
Day 4: Normal Distribution #1 Problems based on basic statistical distributions. Python Medium
Day 4: Normal Distribution #2 Problems based on basic statistical distributions. Python Medium
Normal Distribution #3 Problems based on basic statistical distributions. Python Hard
B’day Gift Whats the price Isaac has to pay for HackerPhone Python Easy
Extremely Dangerous Virus Estimate how large the virus will grow. Python Medium
Binomial Distribution #1 Problems based on basic statistical distributions. Python Medium
Binomial Distribution #2 Problems based on basic statistical distributions. Python Hard
Binomial Distribution #3 Problems based on basic statistical distributions. Python Hard

Linear Algebra Foundations

Name Preview Code Difficulty
Linear Algebra Foundations #1 - Matrix Addition The basics of linear algebra and matrices as required in Machine Learning. text Easy
Linear Algebra Foundations #2 - Matrix Subtraction The basics of linear algebra and matrices as required in Machine Learning. text Easy
Linear Algebra Foundations #3- Matrix Multiplication Matrix Multiplication of 2x2 Matrices Python text Easy
Linear Algebra Foundations #4- Matrix Multiplication Matrix Multiplication of 2x2 Matrices Python Easy
Linear Algebra Foundations #5 - The 100th Power of a Matrix Compute the 100the power of a given matrix. Python Medium
Linear Algebra Foundations #6 - An Equation involving Matrices Solve an equation involving matrices. text Medium
Linear Algebra Foundations #7 - The 1000th Power of a Matrix Compute the 1000th power of the given matrix. Python text Hard
Linear Algebra Foundations #8 - Systems of Equations A system of equations with no solutions. Python Hard
Linear Algebra Foundations #9 - Eigenvalues Compute the Eigenvalues of the following 2x2 matrix. text Hard
Linear Algebra Foundations #10 - Eigenvectors Compute the EigenVectors of the following 2x2 matrix. Python Medium
Determinant of the matrix #1 Basic problems related to determinants. Python Medium
Determinant of the matrix #2 Basic problems related to determinants. text Hard
Determinant of the matrix #3 Basic problems related to determinants. text Medium
Eigenvalue of a Matrix I Basic problems related to eigenvalues. Python Hard
Eigenvalue of matrix #2 Basic problems related to eigenvalues. Python Hard
Eigenvalue of matrix #3 Basic problems related to eigenvalues. Python Hard
Eigenvalue of matrix #4 Basic problems related to eigenvalues. Python Hard