Our Effort to provide you the best solutions requires some appreciation

Please disable your adblocker and refresh, solve me first.

Complete the function solveMeFirst to compute the sum of two integers. Function prototype: int solveMeFirst(int a, int b); where, a is the first integer input. b is the second integer input Return values sum of the above two integers

Simple Array Sum

Given an array of integers, find the sum of its elements. For example, if the array ar = [1,2,3], 1+2+3 = 6 , so return 6 . Function Description Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer. simpleArraySum has the following parameter(s): ar: an array of integers Input Format The first line contains an integer, n, denoting the size of the array. The second line contains n space-separated integers re

Compare the Triplets

Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty. The rating for Alice's challenge is the triplet a = (a[0], a[1], a[2]), and the rating for Bob's challenge is the triplet b = (b[0], b[1], b[2]). The task is to find their comparison points by comparing a[0] with b[0], a[1] with b[1], and a[2] with b[2]. If a[i] > b[i], then Alice is a

A Very Big Sum

In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large. Function Description Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements. aVeryBigSum has the following parameter(s): int ar[n]: an array of integers . Return long: the sum of all array elements Input Format The first line of the input consists of an integer n

Diagonal Difference

Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix arr is shown below: 1 2 3 4 5 6 9 8 9 The left-to-right diagonal = 1+ 5 + 9 = 15. .The right to left diagonal = 3 +5 +9 = 17 . Their absolute difference is |15-17| = 2 . . Function description Complete the diagonal difference function in the editor below. diagonalDifference takes the following parameter: int arr[n][m]: an array of integers

lock

Unlock this article for Free, by logging in

Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website

  • PrepInsta Home
  • HackerRank Placement Papers
  • What is HackerRank?
  • Aptitude Questions
  • Logical Questions
  • Verbal Questions
  • Domain Questions
  • Coding Questions
  • Advanced Coding Questions
  • Pyschometric Test
  • Challenge for Certification
  • Companies using HackerRank platform
  • Get Hiring Updates

PREPINSTA PRIME

  • Prime Video

Get Hiring Updates right in your inbox from PrepInsta

Top 25 Hackerrank Coding Questions and Answers

June 15, 2024

Hackerrank Coding Questions for Practice

Below you can find the Top 25 Hackerrank based coding questions with solutions for the Hackerrank Coding test. in this article we have collected the most asked and most important Hackerrank coding questions that you need to prepare to successfully crack Hackerrank coding round for companies like IBM, Goldman Sachs, Cisco, Mountblu, Cognizant, etc.

Here you can practice all the Top 25 free !!! coding questions that were asked in the latest placement drives held by Hackerrank Hackerrank Coding questions are bit difficulty then the usual coding questions, as most of the product based companies hire through this platform.

HackerRank Coding Questions

Sample Hackerrank Coding Questions

Details about hackerrank as a hiring platform.

TopicsDetails
Number of Questions asked by companies2 – 5
Time Limit2 – 4.5 hrs approx
Difficulty levelHigh
Package Offered6 LPA – 12 LPA

Hackerrank Coding Questions are used by multiple organizations and MNC(s) for hiring coding proficient students, using Hackerrank Platform. For instance Hackerrank regularly hold coding competitions sponsored by specific companies as a result  to hire engineers. However these contests vary in duration, rules, or challenge type/topic, depending on what the sponsor is looking to test for. After the contest, the sponsoring companies contact top performers on the leader-board about job opportunities.

Shortcut keys (hotkeys)  allowed are :

  • alt/option + R : Run code
  • alt/option + Enter : Submit code
  • alt/option + F : Enable full screen
  • Esc : Restore full screen

Use Coupon Code “ CT10 ” and get flat 10% OFF on your Prime Subscription plus one month extra on 12 months and above plans!!

List of Hackerrank Practice Coding Questions

  • Question 10
  • Question 11
  • Question 12
  • Question 13
  • Question 14
  • Question 15
  • Question 16
  • Question 17
  • Question 18
  • Question 19
  • Question 20
  • Question 21
  • Question 22
  • Question 23
  • Question 24
  • Question 25

(Use Coupon Code CT10 and get 10% off plus extra month subscription)

Prime Course Trailer

Related banners.

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Hackerrank Coding Questions with Solutions

Question 1 – maximum passengers.

Problem Statement -: A taxi can take multiple passengers to the railway station at the same time.On the way back to the starting point,the taxi driver may pick up additional passengers for his next trip to the airport.A map of passenger location has been created,represented as a square matrix.

The Matrix is filled with cells,and each cell will have an initial value as follows:

  • A value greater than or equal to zero represents a path.
  • A value equal to 1 represents a passenger.
  • A value equal to -1 represents an obstruction.

The rules of motion of taxi are as follows:

  • The Taxi driver starts at (0,0) and the railway station is at (n-1,n-1).Movement towards the railway station is right or down,through valid path cells.
  • After reaching (n-1,n-1) the taxi driver travels back to (0,0) by travelling left or up through valid path cells.
  • When passing through a path cell containing a passenger,the passenger is picked up.once the rider is picked up the cell becomes an empty path cell. 
  • If there is no valid path between (0,0) and (n-1,n-1),then no passenger can be picked.
  • The goal is to collect as many passengers as possible so that the driver can maximize his earnings.

For example consider the following grid,

           0      1

          -1     0

Start at top left corner.Move right one collecting a passenger. Move down one to the destination.Cell (1,0) is blocked,So the return path is the reverse of the path to the airport.All Paths have been explored and one passenger is collected.

Int : maximum number of passengers that can be collected.

Sample Input 0

4  -> size n = 4

4 -> size m = 4

0 0 0 1 -> mat

Explanation 0

The driver can contain a maximum of 2 passengers by taking the following path (0,0) → (0,1) → (0,2) → (0,3) → (1,3) → (2,3) → (3,3) → (3,2) → (3,1) → (3,0) → (2,0) → (1,0)  → (0,0)

Sample Input 1

 STD IN                  Function 

————              ————-

   3     →  size  n=3

   3    →  size m=3

   0 1 -1 → mat 

Sample Output 1

Explanation 1

The driver can contain a maximum of 5 passengers by taking the following path (0,0) → (0,1) → (1,1) → (2,1) → (2,2) → (2,1) → (2,0) → (1,0) → (0,0) 

Question 2 – Minimum streets lights

Problem Statement -: Street Lights are installed at every position along a 1-D road of length n. Locations[] (an array) represents the coverage limit of these lights. The ith light has a coverage limit of locations[i] that can range from the position max((i – locations[i]), 1) to min((i + locations[i]), n ) (Closed intervals). Initially all the lights are switched off. Find the minimum number of fountains that must be switched on to cover the road.

locations[] = {0, 2, 13}then

For position 1: locations[1] = 0, max((1 – 0),

1) to mini (1+0), 3) gives range = 1 to 1

For position 2: locations[2] = 2, max((2-2),

1) to min( (2+2), 3) gives range = 1 to 3

For position 3: locations[3] = 1, max( (3-1),

1) to min( (3+1), 3) gives range = 2 to 3

For the entire length of this road to be covered, only the light at position 2 needs to be activated.

int : the minimum number of street lights that must be activated

Constraints :

  • 1<_n<_ 10^5
  •  O<_locations[i] <_ mini (n,100) (where 1 <_1<_10^5)

Sample Input For Custom Testing :

3 ->locations[] size n = 3

1 ->locations[] [1, 1, 1]

1 ->Sample Output

Sample Output :

Question 3 – Maximize Earnings

Problem Statement -:  A company has a list of jobs to perform. Each job has a start time, end time and profit value. The manager has asked his employee Anirudh to pick jobs of his choice. Anirudh being greedy wants to select jobs for him in such a way that would maximize his earnings. 

Given a list of jobs how many jobs and total earning are left for other employees once Anirudh

Picks jobs of his choice.

Note : Anirudh can perform only one job at a time.

Input format:

Each Job has 3 pieces of info – Start Time,End Time and Profit

The first line contains the number of Jobs for the day. Say ‘n’. So there will be ‘3n lines following as each job has 3 lines.

Each of the next ‘3n’ lines contains jobs in the following format:

start-time and end-time are in HHMM 24HRS format i.e. 9am is 0900 and 9PM is 2100

Constraints

  • The number of jobs in the day is less than 10000 i.e. 0<_n<_10000
  • Start-time is always less than end time.

Output format :-

Program should return an array of 2 integers where 1st one is number of jobs left and earnings of other employees.

Sample Input 1 :

Sample Output 1:

Sample Explanation 1

Anirudh chooses 1000-1200 jobs. His earnings is 500. The 1st and 3rd jobs i.e. 0900-1030 and 1100-1200 respectively overlap with the 2nd jobs. But profit earned from them will be 400 only. Hence Anirudh chooses 2nd one. Remaining 2 Jobs & 400 cash for other employees.

Sample Input 2:

Sample output 2:

Sample Explanation 2:

Anirudh can work on all appointments as there are none overlapping. Hence 0 appointments and 0 earnings for other employees.

Question 4 : Network Stream

Problem Statement –  A stream of n data packets arrives at a server. This server can only process packets that are exactly 2^n units long for some non-negative integer value of n (0<=n).

All packets are repackaged in order to the 1 largest possible value of 2^n units. The remaining portion of the packet is added to the next arriving packet before it is repackaged. Find the size of the largest repackaged packet in the given stream.

  • arriving Packets = [12, 25, 10, 7, 8]
  • The first packet has 12 units. The maximum value of 2^n that can be made has 2^n = 2^3 = 8 units because the next size up is 2^n = 2^4 = 16 (16 is greater than 12).
  • 12 – 8 = 4 units are added to the next packet. There are 4 + 25 = 29 units to repackage, 2^n = 2^4 = 16 is the new size leaving 9 units (29-16 = 9) Next packet is 9 + 10 = 29 unists & the maximum units(in 2^n) is 16 leaving 3 units.
  • 3 + 7 = 10 , the max units is 8 Leaving 2 units, and so on.
  • The maximum repackaged size is 16 units.
  • Long : the size of the largest packet that is streamed
  • 1<=n<=10^5
  • 1<=arriving Packets[i] size<=10^9

Sample case :

Sample input : 5 → number of packets=5 12 → size of packets=[13,25,12,2,8] 25 10 2 8 Sample output : 16

Question 5 – Astronomy Lecture

Problem Statement -: Anirudh is attending an astronomy lecture. His professor who is very strict asks students to write a program to print the trapezium pattern using stars and dots as shown below . Since Anirudh is not good in astronomy can you help him?

Sample Input:

Question 6 – Disk Space Analysis

Problem Statement -:  You are given an array, You have to choose a contiguous subarray of length ‘k’, and find the minimum of that segment, return the maximum of those minimums.

Sample input 0 

1 →  Length of segment x =1

5 →  size of space n = 5

1 → space = [ 1,2,3,1,2]

Sample output

Explanation

The subarrays of size x = 1 are [1],[2],[3],[1], and [2],Because each subarray only contains 1 element, each value is minimal with respect to the subarray it is in. The maximum of these values is 3. Therefore, the answer is 3

Question 7 : Guess the word

Problem Statement – Kochouseph Chittilappilly went to Dhruv Zplanet , a gaming space, with his friends and played a game called “Guess the Word”. Rules of games are –

  • Computer displays some strings on the screen and the player should pick one string / word if this word matches with the random word that the computer picks then the player is declared as Winner.
  • Kochouseph Chittilappilly’s friends played the game and no one won the game. This is Kochouseph Chittilappilly’s turn to play and he decided to must win the game.
  • What he observed from his friend’s game is that the computer is picking up the string whose length is odd and also that should be maximum. Due to system failure computers sometimes cannot generate odd length words. In such cases you will lose the game anyways and it displays “better luck next time”. He needs your help. Check below cases for better understand

Sample input : 5 → number of strings Hello Good morning Welcome you Sample output : morning

Explanation:

  • Morning → 7
  • Welcome → 7

First word that is picked by computer is morning

Sample input 2 : 3 Go to hell

Sample output 2: Better luck next time

Explanation: Here no word with odd length so computer confuses and gives better luck next time

Question 8 – Minimum Start value

Problem Statement -:  Raman was playing a game, in starting he has x coins at some point of the game he has to pay some coins to get into the next level of the game, during each game he can collect some coins. If at anypoint of the  game numbers of coins of Raman is less than one he will lose the game. Find the minimum value of x such that Raman wins.

Question 9 : Complex Math

Problem Statement – The math assignment says you will be given numbers, mostly with imaginary additions, that means complex numbers, and you need to add them and tell the answer in your answer script. You told your friend John that you don’t know the addition of complex numbers, so John will write a program, which you can write in order to get the results of addition.

John knows Object oriented programming enough to complete the task.

Input Format: Three integers a b and c Output format: First print the complex number a+bi Next line print a + bi + c as i2. Next line i2+a+bi

Sample Input: 4 5 2

Sample Output: 4 + 5i 6 + 5i 10 + 10i

Question 10 : Minimum Occurrence

Problem Statement – Given a sting , return the character that appears the minimum number of times in the string. The string will contain only ascii characters, from the ranges (“a”-”z”,”A”-”Z”,0-9), and case matters . If there is a tie in the minimum number of times a character appears in the string return the character that appears first in the string.

Input Format: Single line with no space denoting the input string.

OutputFormat: Single character denoting the least frequent character.

Constraints: Length of string <=10^6

Sample Input: cdadcda

Sample Output: c

Explanation: C and A both are with minimum frequency. So c is the answer because it comes first with less index.

Question 11 : Devil Groups

Problem Statement –

There are some groups of devils and they splitted into people to kill them. Devils make People to them left as their group and at last the group with maximum length will be killed. Two types of devils are there namely “@” and “$” People is represented as a string “P”

Input Format: First line with the string for input

Output Format: Number of groups that can be formed.

Constraints: 2<=Length of string<=10^9

Input string PPPPPP@PPP@PP$PP

Explanation 4 groups can be formed

Most people in the group lie in group 1 with 7 members.

Question 12 : Vampire Battle

Problem Statement – Stephan is a vampire. And he is fighting with his brother Damon. Vampires get energy from human bloods, so they need to feed on human blood, killing the human beings. Stephan is also less inhuman, so he will like to take less life in his hand. Now all the people’s blood has some power, which increases the powers of the Vampire. Stephan just needs to be more powerful than Damon, killing the least human possible. Tell the total power Steohan will have after drinking the bloods before the battle.

  • Note that: Damon is a beast, so no human being will be left after Damon drinks everyone’s blood. But Stephan always comes early in the town.

Input Format:

First line with the number of people in the town, n.

Second line with a string with n characters, denoting the one digit power in every blood.

Output Format:

Total minimum power Stephan will gather before the battle.

Constraints:

Sample input :

Sample output :

Stephan riches the town, drinks the blood with power 9. Now Damon cannot reach 9 by drinking all the other bloods.

Question 13 : Copycat in exam

Problem Statement –  Rahul copies in the exam from his adjacent students. But he doesn’t want to be caught, so he changes words keeping the letter constant. That means he interchanges the positions of letters in words. You are the examiner and you have to find if he has copied a certain word from the one adjacent student who is giving the same exam, and give Rahul the markings he deserves.

Note that: Uppercase and lowercase are the  same.

  • First line with the adjacent student’s word
  • Second line with Rahul’s word
  • 0 if not copied
  • 1 if copied
  • 1<=Length of string<=10^6

Sample Output:

Question 14 : Mr. Robot’s Password

Problem Statement –  Mr. Robot is making a website, in which there is a tab to create a password. As other websites, there are rules so that the password gets complex and none can predict the password for another. So he gave some rules like:

  • At least one numeric digit
  • At Least one Small/Lowercase Letter
  • At Least one Capital/Uppercase Letter
  • Must not have space 
  • Must not have slash (/)
  • At least 6 characters
  • If someone inputs an invalid password, the code prints: “Invalid password, try again”.

Otherwise, it prints: “password valid”.

A line with a given string as a password

  • Otherwise, it prints: “password valid”, without the quotation marks.
  • Number of character in the given string <=10^9

Sample input 1: 

Sample output 1: 

password valid

Sample input 2: 

Sample output 2: 

Invalid password, try again

Question 15 : Weird Terminal

Problem Statement –  Here is a weird problem in Susan’s terminal. He can not write more than two words each line, if she writes more than two, it takes only 2 words and the rest are not taken. So she needs to use enter and put the rest in a new line. For a given paragraph, how many lines are needed to be written in Susan’s terminal?

  • A string as the text to input in the terminal
  • Number of lines written.
  • Number of words <=10^7

How long do you have to sit dear ?

The writing will be:

Question 16 : Set Bit calculator 

Problem Statement – Angela plays with the different bits. She was given a bunch of numbers and she needs to find how many set bits are there in total. Help Angela to impress her, write a code to do so.

  • First line with n, an integer
  • Next n lines denoting n integers angela is given.
  • Total number of set bits
  • Number of elements or number <=10^7
  • numbers<=10000

Sample Input: 4 1 3 2 1

Sample Output: 5

Question 17 : Duplicates

Problem Statement – The principal has a problem with repetitions. Everytime someone sends the same email twice he becomes angry and starts yelling. His personal assistant filters the mails so that all the unique mails are sent only once, and if there is someone sending the same mail again and again, he deletes them. Write a program which will see the list of roll numbers of the student and find how many emails are to be deleted.

Sample Input: 6 1 3 3 4 3 3

Sample Output: 3

Question 18 : Device Name System

Problem Statement –  Rocky is a software engineer and he is creating his own operating system called “myFirst os”. myFirst os  is a GUI (Graphical user interface) based operating system where everything is stored in files and folders. He is facing issues on  creating unique folder names for the operating system . Help rocky to create the unique folder name for it’s os.If folder name already exists in the system and integer number is added at the name to make it unique. The integer added starts with 1 and is incremented by 1 for each new request of an existing folder name. Given a list of folder names , process all requests and return an array of corresponding folder names.

  • foldername= [‘home’ , ‘myfirst’ ,’downloads’, ‘myfirst’, ‘myfirst’]
  • foldername[0]= ‘home’ is unique.
  • foldername[1]= ‘myfirst’ is unique.
  • foldername [2]=’downloads’ is unique.
  • foldername[3]=’myfirst’ already exists in our system. So Add1 at the end of the folder name i.e foldername[3]=”myfirst1″
  • foldername[4]=’myfirst’ also already exists in our system.So add 2 at the end of the folder name i.e. foldername[4]=”myfirst2″.

folderNameSystem function has the following parameters

  •    string foldername[n]: an array of folder name string in the order requested
  • String[n]:  an array of strings usernames in the order assigned
  •     1<=n<=10^4
  •     1<=length of foldername[i]<20
  •     foldername[i] contains only lowercase english letter in the range ascii[a-z]
  • The first line contains an integer n , denoting the size of the array usernames
  • Each line i of the n subsequent lines (where i<=0<=n) contains a string usernames[i] representing a username request in the order received.

Explanation :

  •    foldername[0] = ‘home’ is unique
  •    foldername[1]=’download’ is unique
  •    foldername[2]= ‘first’ is unique
  •    foldername[3]=’first’ is already existing . so add 1 to it and it become first1

Question 19 : Formatting large Products

Problem Statement – Rohan is weak in mathematics.He is giving mathematics  Olympiad , but he got stuck in one of the question. Help rohan to solve the question.In Question there are two positive integer A and B. You have to find the product of all integer between A and B which is represented in the form C=D*10^E , where  C is the product of numbers , D and E are non-negative integers and the last digit of D is non-zero.

Function Description 

Complete the function formatProducts in the editor below, formatProduct must return a string that represents C in the above described form.

Function has the following parameters

  • A: an integer
  • B: an integer
  •    A will between 1 and 1,000,000 . Inclusive.
  •    B will be between A and 1,000,000. Inclusive.

Sample Input :  

1*2*3*4*5=120 = 12 * 10^1

  Sample Input :

18144 * 10^2

3*4*….*10=1814400 =18144 * 10^2

Question 20 : Maximum Toys

Problem Statement – In a toy shop there are a number of toys presented with several various – priced toys in a specific order. You have a limited budget and would like to select the greatest number of consecutive toys that fit within the budget. Given prices of the toys and your budget, what is the maximum number of toys that can be purchased for your child?

  • prices=[1,4,5,3,2,1,6]

All subarrays that sum to less than or equal to 6 .

  • length 1: [1] [4] [5] [3] [2] [1] [6]
  • length 2: [1,4] [3,2] [2,1]
  • length 3: [3,2,1]

The longest of these or the maximum number of toys that can be purchased is 3.

Function description Complete the function

  • getMaxToys in the editor below
  • getMaxToys has the following parameters: int prices[n] : the prices of the various toys.
  • int money: the amount of money you can spend on toys

Returns : Int the maximum number of toys you can purchase

  • 1<=price[i]<=100
  • 1<=money<=10^6

Sample case

Sample input : 7 1 4 5 3 2 1 6 6 

Question 21 : Maximum Attendance

Problem Statement – A teacher wants to look at students’ attendance data. Given that there is a class , and the teacher has the record of the students present on n days of the month, find the maximum number of consecutive days on which all students were present in the class.

data=[PPPP, PPPP ,PPPP ,PPAP ,AAPP ,PAPA ,AAAA]

There are 4 students and 7 days attendance data . There are only three days, at the beginning where all students are present. Student 3 is absent on the fourth day , and students 1 and 2 are absent on the fifth day , and students 2 and 4 are absent on the sixth day and all are absent on the last day.

The maximum number of consecutive days on which all the students were present in the class is 3 days long.

Function Description :

Complete the maxConsecutive function in the editor below. The function must return an integer denoting the maximum number of consecutive days where all the students are present in the class.

  • int m : the number of students in the class.
  • string data[n] : the value of each element data[i] is a
  • string where data[i] denotes ith student is present on the ith day.
  • 1<=m<=10
  • 1<=n<=31
  • Each data[i][j]={‘P’,’A’}

Input Format :

Sample Output: 1

Explanation : There is only one day in which all the students are present.

Question 22 : Solve equations

Solve the given equations: You will be given an array, and T number of equations. Solve that equation and update the array for every equation you solve Input Example: 2 3 4 5 1 → input array 3 → number of equations x*x x+x 3*x+x

Output: 32 72 128 200 8 Explanation :

  • For first case array becomes arr=[ 4 9 16 25 1]
  • For second case array becomes arr=[8 18 32 50 2]
  • For third case array becomes arr=[32 72 128 200 8]

Output will be : 32 72 128 200 8

Question 23 : Solve equations

Solve the given equations:  There are consecutive lighthouses present in the x axis of a plane.You are given n, which represents the the number of light position and x coordinate array which represent the position of the lighthouses.You have to find maximum lighthouses which have absolute difference less than or equal to 1 between adjacent numbers.

Question 24: Match

Solve the given equations:  The number of matches won by two teams in matches in leagues is given in the form of two lists. For each league score of team B. Compute the total number of matches of team A where team A has won less than or equal to the number of wins scored by team B in that match.

Question 25: jumble the words

Solve the given equations:

Confuse your friends by jumbling the two words given to you. To don’t get yourself into confusion follow a pattern to jumble the letters. Pattern to be followed is , pick a character from the first word and pick another character from the second word. Continue this process

Take two strings as input , create a new string by picking a letter from string1 and then from string2, repeat this until both strings are finished and maintain the subsequence. If one of the strings is exhausted before the other, append the remaining letters from the other string all at once.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Login/Signup to comment

hackerrank problem solving solutions

30+ Companies are Hiring

Codersdaily-logo

  • Create Account

Codersdaily-logo

Book a FREE live class. NOW!

Fill your details and select a date for your live class

HackerRank Java Solutions Logo

HackerRank Java solutions

"HackerRank Java Solutions" is a collection of Java programming solutions curated and designed for HackerRank, an online platform that allows programmers to practice, compete, and improve their coding skills. This compilation offers step-by-step explanations and code snippets to solve various challenges and exercises available on HackerRank, aiding learners in enhancing their proficiency in Java programming through hands-on practice and problem-solving.

HackerRank Java Solutions

  • "Hello, World!" program with Java HackerRank Solution
  • if-else program with Java HackerRank Solutions
  • Loops program with Java HackerRank Solutions.
  • String operations program with Java HackerRank Solutions
  • Lexicographically smallest and largest substrings of length 'k' with Java HackerRank Solutions
  • Substring calculation with Java HackerRank Solutions
  • String Palindrome program with Java HackerRank Solutions
  • Anagram Strings program with Java HackerRank Solutions
  • String Tokens program with Java HackerRank Solutions
  • Print each sequential element on a new line program with Java HackerRank Solutions
  • Print the number of subarrays of an array having negative sums with Java HackerRank solutions.
  • String Balancing program with Java HackerRank Solutions
  • Java Varargs sum program using Java HackerRank solutions
  • Regular expression to validate an IP address using Java HackerRank solution
  • Java Map program using Java HackerRank Solutions
  • Java Sort program using Java HackerRank solutions
  • Java Dequeue program using Java HackerRank solutions
  • Exception handling program using Java HackerRank Solutions
  • Java Abstract class program with Java HackerRank Solutions
  • Regular expression program to remove duplicate words from a string using Java HackerRank Solutions

hackerrank problem solving solutions

Coding Made Simple

HackerRank Solutions in Java

Hello coders, in this post you will find each and every solution of HackerRank Problems in Java Language . After going through the solutions, you will be clearly understand the concepts and solutions very easily.

Java Hackerrank Solution

One more thing to add, don’t straight away look for the solutions, first try to solve the problems by yourself. If you find any difficulty after trying several times, then look for the solutions.

Java HackerRank Solutions

  • Welcome to Java! – Hacker Rank Solution
  • Java Stdin and Stdout I – Hacker Rank Solution
  • Java If-Else – Hacker Rank Solution
  • Java Stdin and Stdout II – Hacker Rank Solution
  • Java Output Formatting – Hacker Rank Solution
  • Java Loops I – Hacker Rank Solution
  • Java Loops II – Hacker Rank Solution
  • Java Datatypes – Hacker Rank Solution
  • Java End-of-file – Hacker Rank Solution
  • Java Static Initializer Block – Hacker Rank Solution
  • Java Int to String – Hacker Rank Solution
  • Java Date and Time – Hacker Rank Solution
  • Java Currency Formatter – Hacker Rank Solution
  • Java Strings Introduction – Hacker Rank Solution
  • Java Substring – Hacker Rank Solution
  • Java Substring Comparisons – Hacker Rank Solution
  • Java String Reverse – Hacker Rank Solution
  • Java Anagrams – Hacker Rank Solution
  • Java String Tokens – Hacker Rank Solution
  • Pattern Syntax Checker – Hacker Rank Solution
  • Java Regex – Hacker Rank Solution
  • Java Regex 2 – Duplicate Words – Hacker Rank Solution
  • Valid Username Regular Expression – Hacker Rank Solution
  • Tag Content Extractor – Hacker Rank Solution
  • Java BigDecimal – Hacker Rank Solution
  • Java Primality Test – Hacker Rank Solution
  • Java BigInteger – Hacker Rank Solution
  • Java 1D Array – Hacker Rank Solution
  • Java 2D Array – Hacker Rank Solution
  • Java Subarray – Hacker Rank Solution
  • Java Arraylist – Hacker Rank Solution
  • Java 1D Array(Part 2) – Hacker Rank Solution
  • Java List – Hacker Rank Solution
  • Java Map – Hacker Rank Solution
  • Java Stack – Hacker Rank Solution
  • Java Hashset – Hacker Rank Solution
  • Java Generics – Hacker Rank Solution
  • Java Comparator – Hacker Rank Solution
  • Java Sort – Hacker Rank Solution
  • Java Dequeue – Hacker Rank Solution
  • Java BitSet – Hacker Rank Solution
  • Java Priority Queue – Hacker Rank Solution
  • Java Inheritance I – Hacker Rank Solution
  • Java Inheritance II – Hacker Rank Solution
  • Java Abstract Class – Hacker Rank Solution
  • Java Interface – Hacker Rank Solution
  • Java Method Overriding – Hacker Rank Solution
  • Java Method Overriding 2 (Super Keyword) – Hacker Rank Solution
  • Java Instanceof Keyword – Hacker Rank Solution
  • Java Iterator – Hacker Rank Solution
  • Java Exception Handling (Try-Catch) – Hacker Rank Solution
  • Java Exception Handling – Hacker Rank Solution
  • Java Varargs – Hacker Rank Solution
  • Java Reflection – Attributes – Hacker Rank Solution
  • Can You Access? – Hacker Rank Solution
  • Prime Checker – Hacker Rank Solution
  • Java Factory Pattern – Hacker Rank Solution
  • Java Singleton Pattern – Hacker Rank Solution
  • Java Visitor Pattern – Hacker Rank Solution
  • Java Annotations – Hacker Rank Solution
  • Covariant Return Types – Hacker Rank Solution
  • Java Lambda Expressions – Hacker Rank Solution
  • Java MD5 – Hacker Rank Solution
  • Java SHA-256 – Hacker Rank Solution

Disclaimer: The above Problem ( Java HackerRank ) is generated by Hacker Rank but the Solution is Provided by CodingBroz . These tutorial are only for Educational and Learning Purpose.

Leave a Comment Cancel Reply

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

"Coffins"

Here is a collection of difficult math problems with elegant solutions that possess a unique history.

  • The main list of problems
  • Problems submitted by others

The history of this collection

Sample solution, other links.

In the summer of 1975, while I was in a Soviet math camp preparing to compete in the International Math Olympiad on behalf of the Soviet Union, my fellow team members and I were approached for help by Valera Senderov, a math teacher in one of the best Moscow special math schools.

The Mathematics Department of Moscow State University, the most prestigious mathematics school in Russia, had at that time been actively trying to keep Jewish students (and other "undesirables") from enrolling in the department. One of the methods they used for doing this was to give the unwanted students a different set of problems on their oral exam. These problems were carefully designed to have elementary solutions (so that the Department could avoid scandals) that were nearly impossible to find. Any student who failed to answer could be easily rejected, so this system was an effective method of controlling admissions. These kinds of math problems were informally referred to as "coffins". "Coffins" is the literal translation from Russian; in English these problems are sometimes called "killer" problems.

These problems and their solutions were, of course, kept secret, but Valera Senderov and his friends had managed to collect a list. In 1975, they approached us to solve these problems, so that they could train the Jewish students in these mathematical ideas. We solved some of them. Here I present some of the "coffin" problems from my archive.

I invite people who faced "killer" problems to send them to me to add to my list.

Problem 31.

A quadrilateral is given in space, such that its edges are tangent to a sphere. Prove that all the points of tangency lie in one plane.

Solution. Begin by observing that each vertex of the quadrilateral is equidistant from the two points of tangency of the edges it is on. With that, put a mass into each vertex of the quadrilateral that is proportional to the inverse of the distance from that vertex to a point of tangency (of an edge it's in). Then the center of mass for any two neighboring vertices is the point of tangency of the edge they share. Then the center of mass of all four vertices should lie on the line connecting opposite points of tangency. That means that the two lines connecting the opposite pairs of points of tangency intersect, so all four of them lie in the plane those two lines define.

  • A. Shen. Entrance examinations to the Mekh-mat , Math. Intelligencer, 16 , 1994.
  • Ilan Vardi's home page. Here you can find solutions to 25 problems published by A. Shen, Entrance Examinations to the Mekh-mat, Mathematical Intelligencer 16 (1994), 6-10.
  • PDF file with Ilan Vardi's solutions.
  • A. Vershik. Admission to the mathematics faculty in Russia in the 1970s and 1980s , Math. Intelligencer, 16 , 1994. - Historical bigraphical article supporting A. Shen's paper
  • Kerosinka: An Episode in the History of Soviet Mathematics , Notices of the AMS, 11 , 1999. - another historical article
  • Epilogue to "Comrade Einstein".
  • Bella Abramovna Subbotovskaya and the "Jewish People's University." An article in AMS Notices Vol. 54, N. 10 (2007), 1326-1330.
  • A discussion on LiveJournal , in Russian.
  • E. Frenkel. The Fifth problem: math & anti-Semitism in the Soviet Union , The New Criterion, 2012.
  • Back to Tanya Khovanova's welcome page

Send mail to: Tanya Khovanova

Last revised August 2008

  • Skills Directory

Problem Solving

Solving problems is the core of computer science. Programmers must first understand how a human solves a problem, then understand how to translate this "algorithm" into something a computer can do, and finally, how to write the specific code to implement the solution. At its core, problem-solving focuses on the study, understanding, and usage of data structures and algorithms. 

This competency area includes basic data structures and algorithms.

Key Competencies:

  • Basic Data Structures  - Use data structures such as arrays and strings. Traverse through arrays, strings, trees, and linked lists. Access and update individual elements in arrays, and characters in strings.
  • Basic Algorithms (such as sorting and searching) - Create simple sorting algorithms such as bubble sort, merge sort, and counting sort. Create simple brute force and sub-optimal solutions. 

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website

Some algorithms for solving linear programming problems with zero-one variables

  • Brief Communications
  • Published: September 1979
  • Volume 15 , pages 760–763, ( 1979 )

Cite this article

hackerrank problem solving solutions

  • B. I. Yukhimenko  

29 Accesses

Explore all metrics

This is a preview of subscription content, log in via an institution to check access.

Access this article

Subscribe and save.

  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime

Price includes VAT (Russian Federation)

Instant access to the full article PDF.

Rent this article via DeepDyve

Institutional subscriptions

Explore related subjects

  • Artificial Intelligence

Literature Cited

B. K. Korobkov, A supplement to the Russian translation of E. Balas's “An additive algorithm for solving linear programming problems with zero-one variables,” in: Kiberneticheskii Sb. Novaya Ser., No. 6, Mir, Moscow (1969).

Google Scholar  

V. P. Grishukhin, “Estimating the complexity of Balas's algorithm,” in: Mathematical Methods for Economic Problem Solving [in Russian], No. 3, Nauka, Moscow (1972).

V. P. Grishukhin, “The mean number of iterations of Balas's algorithm,” in: Studies in Discrete Mathematics [in Russian], Nauka, Moscow (1973).

A. A. Korbut and Yu. Yu. Finkel'shtein, Discrete Programming [in Russian], Nauka, Moscow (1969).

A. A. Panchenko, “Some algorithms for the solution of particular linear programming problems with zero-one variables,” Kibernetika, No. 2 (1976).

I. V. Vengerova and Yu. Yu. Finkel'shtein, “The efficiency of the branch-and-bound method,” Ekonomika Mat. Metody, 10, No. 1 (1975).

V. V. Shkurba and B. I. Yukhimenko, “The convergence of a modification of the branch-and-bound method for solving the integer linear programming problem with zero-one variables,” in: Theory of Optimal Solutions [in Russian], No. 3, Izd. Inst. Kibernet. Akad. Nauk Ukr. SSR, Kiev (1969).

B. I. Yukhimenko, “The block approach to the solution of integer linear-programming problems by the branch-and-bound method,” in: Theoretical and Methodological Principles of Automatic Control System Design [in Russian], Moscow (1974).

Download references

You can also search for this author in PubMed   Google Scholar

Additional information

Translated from Kibernetika, No. 5, pp. 141–143, September–October, 1979.

Rights and permissions

Reprints and permissions

About this article

Yukhimenko, B.I. Some algorithms for solving linear programming problems with zero-one variables. Cybern Syst Anal 15 , 760–763 (1979). https://doi.org/10.1007/BF01071235

Download citation

Received : 21 February 1977

Issue Date : September 1979

DOI : https://doi.org/10.1007/BF01071235

Share this article

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

  • Operating System
  • System Theory
  • Programming Problem
  • Linear Programming Problem
  • Find a journal
  • Publish with us
  • Track your research

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

A collection of solutions to competitive programming exercises on HackerRank.

kilian-hu/hackerrank-solutions

Folders and files.

NameName
4 Commits

Repository files navigation

This is throw-away code that is only supposed to correctly get the job done. I used the code stubs provided by HackerRank, so don't mind the unnecessary imports, naming convention and so on. Feel free to use my solutions as inspiration, but please don't literally copy the code.

Certificates

To get a certificate, two problems have to be solved within 90 minutes.

The following is an incomplete list of possible problems per certificate as of 2021.09.15. Please let me know if the certificate problems have changed, so I can put a note here.

  • Active Traders
  • Balanced System Files Partition
  • Longest Subarray
  • Maximum Cost of Laptop Count
  • Nearly Similar Rectangles
  • Parallel Processing
  • Password Decryption
  • Road Repair
  • String Anagram
  • Subarray Sums
  • Unexpected Demand
  • Usernames Changes
  • Vowel Substring
  • Bitwise AND
  • Equalizing Array Elements
  • File Renaming
  • Hotel Construction
  • Largest Area
  • Maximum Subarray Value
  • Sorted Sums
  • Task of Pairing
  • User-Friendly Password System

Besides the solutions, there are Python 3 and C++ code stubs and some test cases so you can first try to solve the problems without time pressure if you want to.

  • A Very Big Sum [url] [10p]
  • ACM ICPC Team [url] [25p]
  • Angry Professor [url] [20p]
  • Append and Delete [url] [20p]
  • Apple and Orange [url] [10p]
  • Beautiful Days at the Movies [url] [15p]
  • Between Two Sets [url] [10p]
  • Bill Division [url] [10p]
  • Birthday Cake Candles [url] [10p]
  • Breaking the Records [url] [10p]
  • Cats and a Mouse [url] [15p]
  • Circular Array Rotation [url] [20p]
  • Climbing the Leaderboard [url] [20p]
  • Compare the Triplets [url] [10p]
  • Counting Valleys [url] [15p]
  • Cut the sticks [url] [25p]
  • Day of the Programmer [url] [15p]
  • Designer PDF Viewer [url] [20p]
  • Diagonal Difference [url] [10p]
  • Divisible Sum Pairs [url] [10p]
  • Drawing Book [url] [10p]
  • Electronics Shop [url] [15p]
  • Equalize the Array [url] [20p]
  • Extra Long Factorials [url] [20p]
  • Find Digits [url] [25p]
  • Forming a Magic Square [url] [20p]
  • Frog in Maze [url] [65p]
  • Grading Students [url] [10p]
  • Jumping on the Clouds: Revisited [url] [15p]
  • Jumping on the Clouds [url] [20p]
  • Library Fine [url] [15p]
  • Migratory Birds [url] [10p]
  • Mini-Max Sum [url] [10p]
  • Non-Divisible Subset [url] [20p]
  • Number Line Jumps [url] [10p]
  • Organizing Containers of Balls [url] [30p]
  • Picking Numbers [url] [20p]
  • Plus Minus [url] [10p]
  • Queen's Attack II [url] [30p]
  • Repeated String [url] [20p]
  • Sales by Match [url] [10p]
  • Save the Prisoner! [url] [15p]
  • Sequence Equation [url] [20p]
  • Sherlock and Cost [url] [50p]
  • Sherlock and Squares [url] [20p]
  • Simple Array Sum [url] [10p]
  • Staircase [url] [10p]
  • Subarray Division [url] [10p]
  • Taum and B'day [url] [25p]
  • The Hurdle Race [url] [15p]
  • Time Conversion [url] [15p]
  • Utopian Tree [url] [20p]
  • Viral Advertising [url] [15p]
  • Find more efficient solution for Maximum Subarray Value . It's getting timeouts for a few test cases.
  • Verify correctness of Nice Teams .
  • Python 74.3%

IMAGES

  1. 02

    hackerrank problem solving solutions

  2. HackerRank Problem solving Problem Solution

    hackerrank problem solving solutions

  3. Hackerrank Problem Solving(Basics) Solutions

    hackerrank problem solving solutions

  4. Hackerrank-Problem-Solving-Python-Solutions/Fair_Rations.py at master

    hackerrank problem solving solutions

  5. 29

    hackerrank problem solving solutions

  6. Breaking the Records Hackerrank Problem Solving Solution With Detailed Explanation And C++ Code

    hackerrank problem solving solutions

VIDEO

  1. HackerRank Problem Solving Basic Certificate

  2. हिंदी में HackerRank problem solving steps #cprogrmming #c #hackerrank

  3. SQL-2

  4. Day3 hackerrank problem solving staircase problem #codinglife #vlogs #cpp #jobseekers

  5. HackerRank || Solutions || Day 2 || Write a Function

  6. Cracking HackerRank: Solving the Array Sum Problem in C++

COMMENTS

  1. Solutions to Hackerrank practice problems

    170+ solutions to Hackerrank.com practice problems using Python 3, С++ and Oracle SQL Topics. hackerrank hackerrank-python hackerrank-solutions hackerrank-sql Resources. Readme License. MIT license Activity. Stars. 1k stars Watchers. 38 watching Forks. 417 forks Report repository

  2. GitHub

    A collection of solutions for HackerRank data structures and algorithm problems in Python, JAVA, and CPP. This community-owned project aims to bring together the solutions for the DS & Algo problems across various platforms, along with the resources for learning them. Problems from Leetcode will be included soon in the project.

  3. Problem solving

    Solve N problems with increasing difficulty and variety in the least number of days. See input, output, constraints and sample test cases for this algorithm problem.

  4. hackerrank-problem-solutions · GitHub Topics · GitHub

    To associate your repository with the hackerrank-problem-solutions topic, visit your repo's landing page and select "manage topics." GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.

  5. HackerRank Solutions

    Find solutions to various coding problems on HackerRank, such as Solve Me First, Simple Array Sum, Compare the Triplets, and more. Browse by topic, language, or difficulty level and learn from the examples.

  6. Top 25 Hackerrank Coding Questions with Solutions

    PrepInsta offers 25 Hackerrank coding questions with solutions for practice and preparation. Learn how to solve problems related to taxis, street lights, jobs, and more using C++, Java, and Python.

  7. HackerRank Solutions in Python

    Find solutions of HackerRank problems in Python language for various topics such as strings, lists, sets, dictionaries, functions, modules, regex, and more. Learn the concepts and solutions with examples and code snippets.

  8. Solve Python

    Solve Python problems on HackerRank, one of the best ways to prepare for programming interviews. Choose from easy to medium level challenges and see your score and success rate.

  9. HackerRank Java solutions

    Find Java programming solutions for HackerRank challenges with step-by-step explanations and code snippets. Learn and practice various topics such as strings, loops, exceptions, maps, and more on HackerRank.

  10. ALL HackerRank Solutions

    all hackerrank solutions playlist contains efficient solutions for all hackerrank problem solving challenges in java including- hackerrank algorithm solution...

  11. Solutions to Certification of Problem Solving Basic on Hackerrank

    Solutions to Certification of Problem Solving Basic on Hackerrank. To get a certificate, two problems have to be solved within 90 minutes. The following is a list of possible problems per certificate. Problem Solving (Basic) Active Traders; Balanced System Files Partition; Longest Subarray; Maximum Cost of Laptop Count; Nearly Similar Rectangles

  12. Solve C

    Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews.

  13. 7 Tips I Wish I Knew Before Clearing All HackerRank Python Challenges

    You can focus on the problem to be solved instead of the 'logistic codes'. Yet sometimes, I found the provided codes limiting my thinking. Some provided codes will import certain libraries for you, and if you use them, you'll be solving the problem using them. However, the optimum solution might not use the libraries at all.

  14. HackerRank Solutions in Java

    Covariant Return Types - Hacker Rank Solution. Java Lambda Expressions - Hacker Rank Solution. Java MD5 - Hacker Rank Solution. Java SHA-256 - Hacker Rank Solution. Disclaimer: The above Problem (Java HackerRank) is generated by Hacker Rank but the Solution is Provided by CodingBroz. These tutorial are only for Educational and Learning ...

  15. PDF Mathletes Problem of the Week #4 Jumping Checkers

    This is one of his favorite puzzles from Boris Kordemsky's book The Moscow Puzzles. Draw a row of 7 boxes. Place 3 white checkers in squares 1, 2, and 3, and 3 black ones in the squares 5, 6, and 7. To move a checker, you can either move it to the next square if it is open or you can jump over an adjacent checker into the vacant square ...

  16. Solve Java

    Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews.

  17. PDF Math in Moscow program Di erential Geometry Problem Sets

    Di erential Geometry Problem Sets by Prof. Maxim Kazarian Spring 2020 Di erential Geometry Problem Set I 14.02.2020 1. Find the expression for the basic vector elds @ @x and @ @y, and the basic di erential 1-forms dx, dyin the polar coordinates on the plane. 2. Draw the phase portrait and nd the phase ow for the following vector elds on the ...

  18. hackerrank-problem-solving · GitHub Topics · GitHub

    Find public repositories on GitHub that contain solutions to Hackerrank problems in various languages and topics. Browse by stars, issues, pull requests, and update dates to find the best match for your needs.

  19. "Coffins"

    These problems were carefully designed to have elementary solutions (so that the Department could avoid scandals) that were nearly impossible to find. Any student who failed to answer could be easily rejected, so this system was an effective method of controlling admissions. These kinds of math problems were informally referred to as "coffins".

  20. hackerrank-solutions/certificates/problem-solving-intermediate/nice

    A collection of solutions to competitive programming exercises on HackerRank. - kilian-hu/hackerrank-solutions

  21. Problem Solving (Basic)

    Learn how to solve problems using data structures and algorithms. HackerRank offers code challenges and certificates for problem-solving skills.

  22. Some algorithms for solving linear programming problems with zero-one

    V. V. Shkurba and B. I. Yukhimenko, "The convergence of a modification of the branch-and-bound method for solving the integer linear programming problem with zero-one variables," in: Theory of Optimal Solutions [in Russian], No. 3, Izd. Inst. Kibernet. Akad. Nauk Ukr. SSR, Kiev (1969). Google Scholar

  23. GitHub

    To get a certificate, two problems have to be solved within 90 minutes. The following is an incomplete list of possible problems per certificate as of 2021.09.15. Please let me know if the certificate problems have changed, so I can put a note here. Problem Solving (Basic) Active Traders; Balanced System Files Partition; Longest Subarray