6 Problem-Solving HackerRank Questions and Answers for Your Interview

Team CodeQuotient / December 18, 2022 / Software Engineering Bootcamp

6-Problem-Solving-Hackerrank-Questions-and-Answers-to-Help-You-Excel-Your-Interview

HackerRank is a tech company that provides a common platform for programmers and tech companies where people can participate in coding challenges (such as hackathons) or create their own. Most importantly, you can directly land a job from HackerRank if you successfully complete the challenges on its Jobs page . After that comes the interview stage. Usually, HackerRank questions tend to focus largely on problem-solving skills.

Let’s go through 6 problem-solving HackerRank sample questions and answers that can help you perform better in interviews.

Commonly Asked HackerRank Questions and Their Answers

HackerRank interviews have both technical and non-technical questions to evaluate a candidate. Since the people who cleared the coding challenges meet the criteria for technical knowledge, the interviewers majorly focus on other aspects – communication skills, mindset, ethics, etc.

Technical HackerRank Questions

6-Problem-Solving-Hackerrank-Questions-and-Answers-to-Help-You-Excel-Your-Interview

The interviewer may ask you technical interview questions on topics similar to the ones mentioned below.

1. How do you build a palindrome?

One of the most common questions in HackerRank interviews is about building a palindrome. Unless you have a good understanding of strings and dynamic programming, you won’t be able to answer these questions. You need to store the palindromic substrings in a table and use them as building blocks for larger palindromes.

Interviewers love questions about palindromes because they test candidates’ ability to write clean code and their clarity of mind.

2. How do you organise containers of balls?

HackerRank interviewers will often ask you how to arrange coloured balls in various situations.

The answer may depend on the specific situation, as various arrangements may be needed. However, some common structures may include arranging the balls in order of size, colour, alphabetically, or numerically. Additionally, for more complex arrangements, a sorting algorithm could be used to arrange the balls according to the desired criteria.

Questions regarding organising containers of balls test your understanding of 2D arrays, sorting and iteration. Focus on these areas to be comfortable with such questions in HackerRank interviews.

3. How do you solve a problem in the Subarray Division?

Problems on subarray division can be solved in a few lines of code using the ‘two-pointers technique’. This technique works by having two pointers pointing to the array’s beginning and end, respectively, and then looping through the array. Thus, it is a perfect question to test the depth of a candidate’s coding skills , ability to optimise, and basic mathematical skills.

Software developers benefit from knowing the two-pointer technique, which helps them efficiently solve array problems and more. It’s also a common interview subject that comes up frequently. Preparing for problems on subarray division boosts your chances of cracking HackerRank interviews.

Non-Technical Questions

Non-technical questions often reveal more about a candidate’s mindset and problem-solving process in the work environment than technical questions. Here are some non-technical HackerRank questions and answers to better prepare you for interviews:

4. How will you select a new tool to invest in?

Interviewers ask questions like this to evaluate how a candidate does their research about something. While there is no obvious correct answer to this question, your response should show that you’re good at researching a product or service.

The key factors you must keep in mind while answering this question (or similar questions) are:

  • The problem you’re trying to solve with the tool
  • How credible are the people behind the tool?
  • Alternatives of the tool
  • Cost of the tool
  • Pros and cons of the tool

Ensure your answer reflects the way you research anything new.

5. How will you tackle a situation where a teammate is bound to miss a deadline?

There are high chances of you or your teammates missing a few deadlines, be it for avoidable or unavoidable circumstances. When an interviewer asks what you’ll do in such situations, they are trying to figure out how you deal with crises and support your team members. Your answer should reflect empathy and a drive to solve challenges on short notice. Like most non-technical questions, the attitude behind the answer is more important than the contents of the answer.

6. Will you break the rules or guidelines for the larger benefit of the company?

Interviewers love questions that put candidates in a tough spot. That’s why interviewers often ask interviewees why the company should not hire them.

When asked whether you’d be willing to break any rule, be diplomatic in your answer. It is best to back your argument with logic and facts without being rigid on either perspective. Questions like these test a candidate’s character, morals, and ethics.

General Tips for HackerRank Questions and Answers

For those of you who wish to go the extra mile, here are some general suggestions for acing your interview:

  • Follow a framework like STAR (Situation, Task, Action, Result) or SOAR (Situation, Obstacle, Action, Results) to answer problem-solving questions
  • Read the job description thoroughly and understand your job responsibilities
  • Learn about the company – mission and values
  • Work on your speaking skills, either with a friend or in front of a mirror/camera

Get Ready for HackerRank Interviews With Codequotient

Now that you have an idea of how these HackerRank questions would be, we want you to know that in case you need further help to upskill yourself in terms of your technical skills and soft skills, you should know that…

CodeQuotient offers practical resources for anyone who wants to land a tech job. Whether you’re a learner or a job seeker, our BCA+UGPSE and Software Engineering Bootcamp programs can make you job-ready for the upcoming tech industry. Get in touch with us now to know more about these programs!

Get UGC Approved, BCA Degree And Earn While You Do That

Join CodeQuotient's Under-Graduate Program In Software Engineering

Get Paid Internship with Our Hiring Partners to Sponsor Your Fees

100% Placement Assistance

You will also like:

  • Critical Tips To Ace Cognizant Coding Questions
  • CoCubes Login Guide: Eligibility, FAQs, and More
  • TCS NQT 2024: Your Ticket to Hundreds of Placement Opportunities!
  • Wipro Assessment Test 2024: Syllabus and Pattern
  • 8 Top Node.js Questions to Help You Crack Coding Interviews

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

Recent Posts

10 soft skills to acquire before applying for bca courses, cracking the bca placement interview: what you need to know, job prospects vs. personal passion in tech career.

  • BCA Without Maths: Answering Your Top Questions About the Program
  • Tech Career Advice That You Should Know in Your 20s
  • Why Panipat is Emerging as Top Choice for BCA Courses
  • The Misleading Comparison of Fresher Salaries and Blue-Collar Incomes
  • CEO's Corner
  • CodeQuotient School of Technology
  • Engineering High-Performing Teams
  • Software Engineering Bootcamp
  • Uncategorized

You May Also Like .

BCA courses

©️ 2024. All Rights Reserved.

About   |   Blog   |  Contact   |  Privacy Policy   |  Terms and Conditions

hackerrank problem solving questions

What I Learned in Obtaining a Problem Solving (Basic) Hackerrank Certification

Muhammad Nafi' Furqon Diani

Muhammad Nafi' Furqon Diani

The Journey of Obtaining a Problem Solving (Basic) Certification

Recently, I have been wondering if I am a good software engineer? Am I proficient enough in solving problems through coding?

I think i need to test my abilities in problem solving through coding. So, I was able to identify the areas that I needed to improve. Eventually, I decided to try taking the Problem Solving (Basic) certification exam from Hackerrank .

The exam had 2 coding test problems that had to be completed within 90 minutes. If passed, we would receive the certificate around 30 minutes after the exam. If failed, we would have to retake the exam around 30 days after the exam. Unfortunately, I failed. I found it difficult to solve the problems, even for one question.

Then, I remembered the message from Ainun Najib when he was invited on the Insinyur Online YouTube channel run by Giovani Sakti and Iqbal Farabi . He said:

“Be better every day. If you fall, just be better. If you fall today, just be better tomorrow than you were today. As long as you are improving every day, not only you will be fine, but you will be super successful in life.”

From then on, I tried to find ways to improve myself in the future. I searched for ways to pass the certification exam. And then I joined a 1-month preparation kit provided by hackerrank.

There are problem-solving questions that we can solve within 1 month. It is divided into 4 weeks where each week has around 12–16 practice questions and 1 mock test question.

Additionally, I also bought a Udemy course to learn algorithms and data structures using javascript.

I attempted to retake the test after learning from that sources. However, despite my efforts, I was still unsuccessful in passing the test. I was able to complete one problem within 45 minutes but failed several unit tests because my solution was considered slow or less optimal. I tried various methods but still couldn’t pass before the time ran out. As a result, I failed again in this attempt.

Then, I continued to learn from the two sources that I previously mentioned. When I got access to retake the exam again, I did it even though I hadn’t finished the two courses yet.

This time, I was able to quickly solve one problem, around 20–30 minutes. However, I encountered the same problem, that is my code is considered less optimal so it could not pass some of the provided unit tests.

After thinking for quite some time, I finally found a way to optimize the code that I created. From having a time complexity of O(n²) to O(n). Then successfully passed all unit tests. One problem solved.

However, the time was not enough for me to complete the second question. Nevertheless, I received an email that I have passed the Problem Solving (Basic) certification .

Lesson Learned

There are two things that I learned. First, from the hard skills perspective. In coding, it’s not enough to just solve the problem. But we also need to make it more optimal so that the program we create can be more scalable. It must have good performance, whether used by a few or many users. Still optimal whether with a small or large input.

Second, from the soft skills perspective. Wherever we are, in any field, we must have a never-give-up mentality. We should always strive to be better than before.

Muhammad Nafi' Furqon Diani

Written by Muhammad Nafi' Furqon Diani

Software Engineer

Text to speech

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 questions

30+ Companies are Hiring

HackerRank SQL Problem Solving Questions With Solutions

HackerRank SQL Problem Solving Questions With Solutions

1. Revising the Select Query I | Easy | HackerRank

Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA.

The CITY table is described as follows:

hackerrank problem solving questions

2. Revising the Select Query II | Easy | HackerRank

Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.

3. Select All | Easy | HackerRank

Query all columns (attributes) for every row in the CITY table.

4. Select By ID | Easy | HackerRank

Query all columns for a city in CITY with the ID 1661.

5. Japanese Cities' Attributes | Easy | HackerRank

Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN.

6. Japanese Cities' Names | Easy | HackerRank

Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN.

7. Average Population | Easy | HackerRank

Query the average population for all cities in CITY , rounded down to the nearest integer.

Input Format The CITY table is described as follows:

8. Japan Population | Easy | HackerRank

Query the sum of the populations for all Japanese cities in CITY . The COUNTRYCODE for Japan is JPN .

9. Revising Aggregations - The Count Function | Easy | HackerRank

Query a count of the number of cities in CITY having a Population larger than 100,000 .

10. Revising Aggregations - The Sum Function | Easy | HackerRank

Query the total population of all cities in CITY where District is California .

11. Revising Aggregations - Averages | Easy | HackerRank

Query the average population of all cities in CITY where District is California .

12. Population Density Difference | Easy | HackerRank

Query the difference between the maximum and minimum populations in CITY.

13. African Cities | Easy | HackerRank

Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'.

Note : CITY.CountryCode and COUNTRY.Code are matching key columns.

Input Format The CITY and COUNTRY tables are described as follows:

hackerrank problem solving questions

14. Asian Population | Easy | HackerRank

Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is 'Asia'.

Note : CITY.CountryCode and COUNTRY .Code are matching key columns.

Input Format

15. Average Population of Each Continent | Easy | HackerRank

Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer.

16. Weather Observation Station 1 | Easy | HackerRank

Query a list of CITY and STATE from the STATION table. The STATION table is described as follows:

hackerrank problem solving questions

where LAT_N is the northern latitude and LONG_W is the western longitude.

17. Weather Observation Station 2 | Easy | HackerRank

Query the following two values from the STATION table:

  • The sum of all values in LAT_N rounded to a scale of 2 decimal places.
  • The sum of all values in LONG_W rounded to a scale of 2 decimal places.

The STATION table is described as follows:

Output Format

Your results must be in the form:

where lat is the sum of all values in LAT_N and lon is the sum of all values in LONG_W. Both results must be rounded to a scale of 2 decimal places.

18. Weather Observation Station 3 | Easy | HackerRank

Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer. The STATION table is described as follows

19. Weather Observation Station 4 | Easy | HackerRank

Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table. The STATION table is described as follows:

For example, if there are three records in the table with CITY values 'New York', 'New York', 'Bengalaru', there are 2 different city names: 'New York' and 'Bengalaru'. The query returns 1, because

total number of records - number of unique city names = 3 - 2 = 1

20. Weather Observation Station 5 | Easy | HackerRank

Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically. The STATION table is described as follows:

Sample Input

For example, CITY has four entries: DEF , ABC , PQRS and WXY .

Sample Output

Explanation

When ordered alphabetically, the CITY names are listed as ABC , DEF , PQRS , and WXY , with lengths and . The longest name is PQRS , but there are options for shortest named city. Choose ABC , because it comes first alphabetically.

Note You can write two separate queries to get the desired output. It need not be a single query.

21. Weather Observation Station 6 | Easy | HackerRank

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION . Your result cannot contain duplicates.

22. Weather Observation Station 7 | Easy | HackerRank

Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION . Your result cannot contain duplicates.

23. Weather Observation Station 8 | Easy | HackerRank

Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.

24. Weather Observation Station 9 | Easy | HackerRank

Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.

25. Weather Observation Station 10 | Easy | HackerRank

Query the list of CITY names from STATION that do not end with vowels. Your result cannot contain duplicates.

26. Weather Observation Station 11 | Easy | HackerRank

Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.

27. Weather Observation Station 12 | Easy | HackerRank

Query the list of CITY names from STATION that do not start with vowels and do not end with vowels. Your result cannot contain duplicates.

28. Weather Observation Station 13 | Easy | HackerRank

Query the sum of Northern Latitudes (LAT_N) from STATION having values greater than 38.7880 and less than 137.2345 . Truncate your answer to 4 decimal places.

29. Weather Observation Station 14 | Easy | HackerRank

Query the greatest value of the Northern Latitudes (LAT_N) from STATION that is less than 137.2345 . Truncate your answer to 4 decimal places.

30. Weather Observation Station 15 | Easy | HackerRank

Query the Western Longitude (LONG_W) for the largest Northern Latitude (LAT_N) in STATION that is less than 137.2345 . Round your answer to 4 decimal places.

31. Weather Observation Station 16 | Easy | HackerRank

Query the smallest Northern Latitude (LAT_N) from STATION that is greater than 38.7780 . Round your answer to 4 decimal places.

32. Weather Observation Station 17 | Easy | HackerRank

Query the Western Longitude (LONG_W)where the smallest Northern Latitude (LAT_N) in STATION is greater than 38.7780 . Round your answer to 4 decimal places.

33. Weather Observation Station 18 | Medium | HackerRank

Consider P 1 (a, b) and P 2 (c, d) to be two points on a 2D plane.

  • a happens to equal the minimum value in Northern Latitude (LAT_N in STATION ).
  • b happens to equal the minimum value in Western Longitude (LONG_W in STATION ).
  • c happens to equal the maximum value in Northern Latitude (LAT_N in STATION ).
  • d happens to equal the maximum value in Western Longitude (LONG_W in STATION ). Query the Manhattan Distance between points P 1 and P 2 and round it to a scale of 4 decimal places

34. Weather Observation Station 19 | Medium | HackerRank

Consider P 1 (a, c) and P 2 (b, d) to be two points on a 2D plane where (a, b) are the respective minimum and maximum values of Northern Latitude (LAT_N) and (c, d) are the respective minimum and maximum values of Western Longitude (LONG_W) in STATION .

Query the Euclidean Distance between points P 1 and P 2 and format your answer to display 4 decimal digits.

35. Weather Observation Station 20 | Medium | HackerRank

A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to 4 decimal places.

36. Higher Than 75 Marks | Easy | HackerRank

Query the Name of any student in STUDENTS who scored higher than 75 Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID.

The STUDENTS table is described as follows:

hackerrank problem solving questions

The Name column only contains uppercase (A-Z) and lowercase (a-z) letters.

hackerrank problem solving questions

Only Ashley, Julia, and Belvet have Marks > 75 . If you look at the last three characters of each of their names, there are no duplicates and 'ley' < 'lia' < 'vet'.

37. Employee Names | Easy | HackerRank

Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order.

The Employee table containing employee data for a company is described as follows:

hackerrank problem solving questions

where employee_id is an employee's ID number, name is their name, months is the total number of months they've been working for the company, and salary is their monthly salary.

hackerrank problem solving questions

38. Employee Salaries | Easy | HackerRank

Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than $2000 per month who have been employees for less than 10 months. Sort your result by ascending employee_id.

where employee_id is an employee's ID number, name is their name, months is the total number of months they've been working for the company, and salary is the their monthly salary.

Angela has been an employee for 1 month and earns $3443 per month.

Michael has been an employee for 6 months and earns $2017 per month.

Todd has been an employee for 5 months and earns $3396 per month.

Joe has been an employee for 9 months and earns $3573 per month.

We order our output by ascending employee_id.

39. Top Earners | Easy | HackerRank

We define an employee's total earnings to be their monthly salary × months worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings. Then print these values as 2 space-separated integers.

The table and earnings data is depicted in the following diagram:

hackerrank problem solving questions

The maximum earnings value is 69952 . The only employee with earnings = 69952 is Kimberly, so we print the maximum earnings value ( 69952 ) and a count of the number of employees who have earned $69952 (which is 1 ) as two space-separated values.

40. The Blunder | Easy | HackerRank

Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's 0 key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeros removed), and the actual average salary.

Write a query calculating the amount of error (i.e.: actual - miscalculated average monthly salaries), and round it up to the next integer.

The EMPLOYEES table is described as follows:

hackerrank problem solving questions

Note : Salary is per month.

Constraints

1000 < Salary < 10 5 .

hackerrank problem solving questions

Explanation The table below shows the salaries without zeros as they were entered by Samantha:

hackerrank problem solving questions

Samantha computes an average salary of 98.00 . The actual average salary is 2159.00 .

The resulting error between the two calculations is 2159.00 - 98.00 = 2061.00 . Since it is equal to the integer 2061 , it does not get rounded up.

41. Type of Triangle | Easy | HackerRank

Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:

  • Equilateral : It's a triangle with 3 sides of equal length.
  • Isosceles : It's a triangle with 2 sides of equal length.
  • Scalene : It's a triangle with 3 sides of differing lengths.
  • Not A Triangle : The given values of A, B, and C don't form a triangle.

The TRIANGLES table is described as follows:

hackerrank problem solving questions

Each row in the table denotes the lengths of each of a triangle's three sides.

hackerrank problem solving questions

Values in the tuple **(20, 20, 23)**form an Isosceles triangle, because A ≡ B . Values in the tuple (20, 20, 20) form an Equilateral triangle, because A ≡ B ≡ C . Values in the tuple (20, 21, 22) form a Scalene triangle, because A ≠ B ≠ C . Values in the tuple (13, 14, 30) cannot form a triangle because the combined value of sides A and B is not larger than that of side C .

42. The PADS | Medium | HackerRank

Generate the following two result sets:

  • Query an alphabetically ordered list of all names in OCCUPATIONS , immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S).
  • Query the number of ocurrences of each occupation in OCCUPATIONS . Sort the occurrences in ascending order, and output them in the following format:

There are a total of [occupation_count] [occupation]s.

where [occupation_count] is the number of occurrences of an occupation in OCCUPATIONS and [occupation] is the lowercase occupation name. If more than one Occupation has the same [occupation_count], they should be ordered alphabetically.

Note : There will be at least two entries in the table for each type of occupation.

hackerrank problem solving questions

The OCCUPATIONS table is described as follows: Occupation will only contain one of the following values: Doctor , Professor , Singer or Actor .

An OCCUPATIONS table that contains the following records:

hackerrank problem solving questions

The results of the first query are formatted to the problem description's specifications. The results of the second query are ascendingly ordered first by number of names corresponding to each profession (2 ≤ 2 ≤ 3 ≤ 3), and then alphabetically by profession (doctor ≤ singer, and actor ≤ professor).

43. The Report | Medium | HackerRank

You are given two tables: Students and Grades. Students contains three columns ID, Name and Marks.

hackerrank problem solving questions

Grades contains the following data:

hackerrank problem solving questions

Ketty gives Eve a task to generate a report containing three columns: Name, Grade and Mark. Ketty doesn't want the NAMES of those students who received a grade lower than 8. The report must be in descending order by grade -- i.e. higher grades are entered first. If there is more than one student with the same grade (8-10) assigned to them, order those particular students by their name alphabetically. Finally, if the grade is lower than 8, use "NULL" as their name and list them by their grades in descending order. If there is more than one student with the same grade (1-7) assigned to them, order those particular students by their marks in ascending order.

Write a query to help Eve.

hackerrank problem solving questions

Print "NULL" as the name if the grade is less than 8.

Consider the following table with the grades assigned to the students:

hackerrank problem solving questions

So, the following students got 8, 9 or 10 grades:

  • Maria (grade 10)
  • Jane (grade 9)
  • Julia (grade 9)
  • Scarlet (grade 8)

44. Top Competitors | Medium | HackerRank

Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number of challenges, then sort them by ascending hacker_id.

The following tables contain contest data:

  • Hackers: The hacker_id is the id of the hacker, and name is the name of the hacker.

hackerrank problem solving questions

  • Difficulty: The difficult_level is the level of difficulty of the challenge, and score is the score of the challenge for the difficulty level.

hackerrank problem solving questions

  • Challenges: The challenge_id is the id of the challenge, the hacker_id is the id of the hacker who created the challenge, and difficulty_level is the level of difficulty of the challenge.

hackerrank problem solving questions

  • Submissions: The submission_id is the id of the submission, hacker_id is the id of the hacker who made the submission, challenge_id is the id of the challenge that the submission belongs to, and score is the score of the submission.

hackerrank problem solving questions

Hackers Table:

hackerrank problem solving questions

Difficulty Table:

hackerrank problem solving questions

Challenges Table:

hackerrank problem solving questions

Submissions Table:

hackerrank problem solving questions

Hacker 86870 got a score of 30 for challenge 71055 with a difficulty level of 2, so 86870 earned a full score for this challenge.

Hacker 90411 got a score of 30 for challenge 71055 with a difficulty level of 2, so 90411 earned a full score for this challenge.

Hacker 90411 got a score of 100 for challenge 66730 with a difficulty level of 6, so 90411 earned a full score for this challenge.

Only hacker 90411 managed to earn a full score for more than one challenge, so we print the their hacker_id and name as 2 space-separated values.

45. Challenges | Medium | HackerRank

Julia asked her students to create some coding challenges. Write a query to print the hacker_id, name, and the total number of challenges created by each student. Sort your results by the total number of challenges in descending order. If more than one student created the same number of challenges, then sort the result by hacker_id. If more than one student created the same number of challenges and the count is less than the maximum number of challenges created, then exclude those students from the result.

The following tables contain challenge data:

hackerrank problem solving questions

Sample Input 0

hackerrank problem solving questions

Sample Output 0

Sample Input 1

hackerrank problem solving questions

Sample Output 1

For Sample Case 0, we can get the following details:

hackerrank problem solving questions

Students 5077 and 62743 both created 4 challenges, but the maximum number of challenges created is 6 so these students are excluded from the result.

For Sample Case 1, we can get the following details:

hackerrank problem solving questions

Students 12299 and 34856 both created 6 challenges. Because 6 is the maximum number of challenges created, these students are included in the result.

46. Contest Leaderboard | Medium | HackerRank

You did such a great job helping Julia with her last coding contest challenge that she wants you to work on this one, too!

The total score of a hacker is the sum of their maximum scores for all of the challenges. Write a query to print the hacker_id, name, and total score of the hackers ordered by the descending score. If more than one hacker achieved the same total score, then sort the result by ascending hacker_id. Exclude all hackers with a total score of 0 from your result.

hackerrank problem solving questions

  • Submissions: The submission_id is the id of the submission, hacker_id is the id of the hacker who made the submission, challenge_id is the id of the challenge for which the submission belongs to, and score is the score of the submission.

hackerrank problem solving questions

Hacker 4071 submitted solutions for challenges 19797 and 49593, so the total score = 95 + max(43, 96) = 191 .

Hacker 74842 submitted solutions for challenges 19797 and 63132, so the total score = max(98, 5) + 76 = 174 .

Hacker 84072 submitted solutions for challenges 49593 and 63132, so the total score = 100 + 0 = 100 .

The total scores for hackers 4806, 26071, 80305, and 49438 can be similarly calculated.

47. 15 Days of Learning SQL | Hard | HackerRank

Julia conducted a 15 days of learning SQL contest. The start date of the contest was March 01, 2016 and the end date was March 15, 2016.

Write a query to print total number of unique hackers who made at least 1 submission each day (starting on the first day of the contest), and find the hacker_id and name of the hacker who made maximum number of submissions each day. If more than one such hacker has a maximum number of submissions, print the lowest hacker_id. The query should print this information for each day of the contest, sorted by the date.

The following tables hold contest data:

hackerrank problem solving questions

  • Submissions: The submission_date is the date of the submission, submission_id is the id of the submission, hacker_id is the id of the hacker who made the submission, and score is the score of the submission.

hackerrank problem solving questions

For the following sample input, assume that the end date of the contest was March 06, 2016.

hackerrank problem solving questions

On March 01, 2016 hackers 20703 , 36396 , 53473 , and 79722 made submissions. There are 4 unique hackers who made at least one submission each day. As each hacker made one submission, 20703 is considered to be the hacker who made maximum number of submissions on this day. The name of the hacker is Angela.

On March 02, 2016 hackers 15758 , 20703 , and 79722 made submissions. Now 20703 and 79722 were the only ones to submit every day, so there are 2 unique hackers who made at least one submission each day. 79722 made 2 submissions, and name of the hacker is Michael.

On March 03, 2016 hackers 20703 , 36396 , and 79722 made submissions. Now 20703 and 79722 were the only ones, so there are 2 unique hackers who made at least one submission each day. As each hacker made one submission so 20703 is considered to be the hacker who made maximum number of submissions on this day. The name of the hacker is Angela.

On March 04, 2016 hackers 20703 , 44065 , 53473 , and 79722 made submissions. Now 20703 and 79722 only submitted each day, so there are unique 2 hackers who made at least one submission each day. As each hacker made one submission so 20703 is considered to be the hacker who made maximum number of submissions on this day. The name of the hacker is Angela.

On March 05, 2016 hackers 20703 , 36396 , 38289 and 62529 made submissions. Now 20703 only submitted each day, so there is only 1 unique hacker who made at least one submission each day. 36396 made 2 submissions and name of the hacker is Frank.

On March 06, 2016 only 20703 made submission, so there is only 1 unique hacker who made at least one submission each day. 20703 made 1 submission and name of the hacker is Angela.

48. Binary Tree Nodes | Medium | HackerRank

You are given a table, BST, containing two columns: N and P, where N represents the value of a node in Binary Tree, and P is the parent of N.

hackerrank problem solving questions

Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node:

  • Root: If node is root node.
  • Leaf: If node is leaf node.
  • Inner: If node is neither root nor leaf node.

hackerrank problem solving questions

The Binary Tree below illustrates the sample:

hackerrank problem solving questions

49. New Companies | Medium | HackerRank

Amber's conglomerate corporation just acquired some new companies. Each of the companies follows this hierarchy:

hackerrank problem solving questions

Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code.

  • The tables may contain duplicate records.
  • The company_code is string, so the sorting should not be numeric . For example, if the company_codes are C_1, C_2, and C_10, then the ascending company_codes will be C_1, C_10, and C_2.

The following tables contain company data:

  • Company: The company_code is the code of the company and founder is the founder of the company.

hackerrank problem solving questions

  • Lead_Manager: The lead_manager_code is the code of the lead manager, and the company_code is the code of the working company.

hackerrank problem solving questions

  • Senior_Manager: The senior_manager_code is the code of the senior manager, the lead_manager_code is the code of its lead manager, and the company_code is the code of the working company.

hackerrank problem solving questions

  • Manager: The manager_code is the code of the manager, the senior_manager_code is the code of its senior manager, the lead_manager_code is the code of its lead manager, and the company_code is the code of the working company.

hackerrank problem solving questions

  • Employee: The employee_code is the code of the employee, the manager_code is the code of its manager, the senior_manager_code is the code of its senior manager, the lead_manager_code is the code of its lead manager, and the company_code is the code of the working company.

hackerrank problem solving questions

Company Table:

hackerrank problem solving questions

Lead_Manager Table:

hackerrank problem solving questions

Senior_Manager Table:

hackerrank problem solving questions

Manager Table:

hackerrank problem solving questions

Employee Table:

hackerrank problem solving questions

In company C1, the only lead manager is LM1. There are two senior managers, SM1 and SM2, under LM1. There is one manager, M1, under senior manager SM1. There are two employees, E1 and E2, under manager M1.

In company C2, the only lead manager is LM2. There is one senior manager, SM3, under LM2. There are two managers, M2 and M3, under senior manager SM3. There is one employee, E3, under manager M2, and another employee, E4, under manager, M3.

50. Draw The Triangle 1 | Easy | HackerRank

P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):

Write a query to print the pattern P(20).

51. Draw The Triangle 2 | Easy | HackerRank

52. print prime numbers | medium | hackerrank.

Write a query to print all prime numbers less than or equal to 1000 . Print your result on a single line, and use the ampersand ( & ) character as your separator (instead of a space).

For example, the output for all prime numbers ≤ 10 would be :

53. Ollivander's Inventory | Medium | HackerRank

Harry Potter and his friends are at Ollivander's with Ron, finally replacing Charlie's old broken wand.

Hermione decides the best way to choose is by determining the minimum number of gold galleons needed to buy each non-evil wand of high power and age. Write a query to print the id, age, coins_needed, and power of the wands that Ron's interested in, sorted in order of descending power. If more than one wand has same power, sort the result in order of descending age.

The following tables contain data on the wands in Ollivander's inventory:

  • Wands: The id is the id of the wand, code is the code of the wand, coins_needed is the total number of gold galleons needed to buy the wand, and power denotes the quality of the wand (the higher the power, the better the wand is).

hackerrank problem solving questions

Wands Table:

hackerrank problem solving questions

Wands_Property Table:

hackerrank problem solving questions

The data for wands of age 45 (code 1):

hackerrank problem solving questions

  • The minimum number of galleons needed for wand(age = 45, power = 2) = 6020
  • The minimum number of galleons needed for wand(age = 45, power = 10) = 1647

The data for wands of age 40 (code 2):

hackerrank problem solving questions

  • The minimum number of galleons needed for wand(age = 40, power = 1) = 5408
  • The minimum number of galleons needed for wand(age = 40, power = 3) = 3312
  • The minimum number of galleons needed for wand(age = 40, power = 5) = 7587
  • The minimum number of galleons needed for wand(age = 40, power = 7) = 6018

The data for wands of age 20 (code 4):

hackerrank problem solving questions

  • The minimum number of galleons needed for wand(age = 20, power = 5) = 504
  • The minimum number of galleons needed for wand(age = 20, power = 6) = 7651
  • The minimum number of galleons needed for wand(age = 20, power = 8) = 3688

The data for wands of age 17 (code 5):

hackerrank problem solving questions

  • The minimum number of galleons needed for wand(age = 17, power = 3) = 5689
  • The minimum number of galleons needed for wand(age = 17, power = 10) = 9897

54. Symmetric Pairs | Medium | HackerRank

You are given a table, Functions, containing two columns: X and Y.

hackerrank problem solving questions

Two pairs (X 1 , Y 1 ) and (X 2 , Y 2 ) are said to be symmetric pairs if X 1 = Y 2 and X 2 = Y 1 .

Write a query to output all such symmetric pairs in ascending order by the value of X. List the rows such that X 1 ≤ Y 1 .

hackerrank problem solving questions

55. Interviews | Hard | HackerRank

Samantha interviews many candidates from different colleges using coding challenges and contests. Write a query to print the contest_id, hacker_id, name, and the sums of total_submissions, total_accepted_submissions, total_views, and total_unique_views for each contest sorted by contest_id. Exclude the contest from the result if all four sums are 0 .

Note : A specific contest can be used to screen candidates at more than one college, but each college only holds 1 screening contest.

The following tables hold interview data:

  • Contests: The contest_id is the id of the contest, hacker_id is the id of the hacker who created the contest, and name is the name of the hacker.

hackerrank problem solving questions

  • Colleges: The college_id is the id of the college, and contest_id is the id of the contest that Samantha used to screen the candidates.

hackerrank problem solving questions

  • Challenges: The challenge_id is the id of the challenge that belongs to one of the contests whose contest_id Samantha forgot, and college_id is the id of the college where the challenge was given to candidates.

hackerrank problem solving questions

  • View_Stats: The challenge_id is the id of the challenge, total_views is the number of times the challenge was viewed by candidates, and total_unique_views is the number of times the challenge was viewed by unique candidates.

hackerrank problem solving questions

Contests Table:

hackerrank problem solving questions

Colleges Table:

hackerrank problem solving questions

View_Stats Table:

hackerrank problem solving questions

Submission_Stats Table:

hackerrank problem solving questions

The contest 66406 is used in the college 11219 . In this college 11219 , challenges 18765 and 47127 are asked, so from the view and submission stats:

Sum of total submissions = 27 + 56 + 28 = 111

Sum of total accepted submissions = 10 + 18 + 11 = 39

Sum of total views = 43 + 72 + 26 + 15 = 156

Sum of total unique views = 10 + 13 + 19 + 14 = 56

Similarly, we can find the sums for contests 66556 and 94828 .

56. SQL Project Planning | Medium | HackerRank

You are given a table, Projects, containing three columns: Task_ID, Start_Date and End_Date. It is guaranteed that the difference between the End_Date and the Start_Date is equal to 1 day for each row in the table.

hackerrank problem solving questions

If the End_Date of the tasks are consecutive, then they are part of the same project. Samantha is interested in finding the total number of different projects completed.

Write a query to output the start and end dates of projects listed by the number of days it took to complete the project in ascending order. If there is more than one project that have the same number of completion days, then order by the start date of the project.

hackerrank problem solving questions

The example describes following four projects:

  • Project 1: Tasks 1, 2 and 3 are completed on consecutive days, so these are part of the project. Thus start date of project is 2015-10-01 and end date is 2015-10-04, so it took 3 days to complete the project.
  • Project 2: Tasks 4 and 5 are completed on consecutive days, so these are part of the project. Thus, the start date of project is 2015-10-13 and end date is 2015-10-15, so it took 2 days to complete the project.
  • Project 3: Only task 6 is part of the project. Thus, the start date of project is 2015-10-28 and end date is 2015-10-29, so it took 1 day to complete the project.
  • Project 4: Only task 7 is part of the project. Thus, the start date of project is 2015-10-30 and end date is 2015-10-31, so it took 1 day to complete the project.

57. Placements | Medium | HackerRank

You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID (ID of the ONLY best friend). Packages contains two columns: ID and Salary (offered salary in $ thousands per month).

hackerrank problem solving questions

Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be ordered by the salary amount offered to the best friends. It is guaranteed that no two students got same salary offer.

hackerrank problem solving questions

See the following table:

hackerrank problem solving questions

  • Samantha's best friend got offered a higher salary than her at 11.55
  • Julia's best friend got offered a higher salary than her at 12.12
  • Scarlet's best friend got offered a higher salary than her at 15.2
  • Ashley's best friend did NOT get offered a higher salary than her

The name output, when ordered by the salary offered to their friends, will be:

58. Occupations | Medium | HackerRank

Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively.

Note : Print NULL when there are no more names corresponding to an occupation.

The OCCUPATIONS table is described as follows:

hackerrank problem solving questions

Occupation will only contain one of the following values: Doctor , Professor , Singer or Actor .

hackerrank problem solving questions

The first column is an alphabetically ordered list of Doctor names. The second column is an alphabetically ordered list of Professor names. The third column is an alphabetically ordered list of Singer names. The fourth column is an alphabetically ordered list of Actor names. The empty cell data for columns with less than the maximum number of names per occupation (in this case, the Professor and Actor columns) are filled with NULL values.

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 questions

HackerRank Candidates Help Center home page

Frequently Asked Questions During the Test

  • Updated February 20, 2024 18:14

General FAQ

What accommodations are available for hackerrank tests.

At HackerRank, we are continually innovating, creating, and designing to give the candidates of our platform the ability to accomplish more. One way we fulfill this objective is by committing to a diverse and inclusive culture in the hiring space. We comply with the WCAG 2.1 AA Standards to make our content accessible to a broader range of candidates with disabilities, including but not limited to blindness, deafness, cognitive limitations, and others.

For more information, check the HackerRank's Approach to Accessibility article.

How to know the duration or time allocated for a Test?

The test setters at the hiring company design your HackerRank Tests and determine the test schedule and duration.

  • Check the test email invite from the recruiter to know the schedule period and the allocated time to complete the test.

Duration.png

  • The timer starts at the moment you log in to the test. As you attempt the questions, keep an eye on the remaining time.

Time_2.png

HackerRank only provides a platform to conduct the challenges. For help regarding the test schedule, time extension, and evaluation of tests, directly contact the recruiter of the concerned company.

What happens if there is a loss of internet connectivity while taking a Test?

All the work you submitted before losing the internet connection is saved on our servers. After the internet connectivity is resumed, you can log on to the test again (if it is not past the test completion time) and resume answering the questions. The test timer does not stop ticking when you are offline, and the test ends at the scheduled time.

You can request the recruiter who invited you to the test to give you an extension because of the lost time. They can allow additional time for you to complete the test. They can give you a time duration extension to complete the Tests in progress and send you re-invites to retake a Test.

However, it is best to check your computer and internet connection before taking the test. HackerRank only provides a platform to conduct the challenges and cannot allow you extra time to complete the test. For help regarding the test schedule, time extension, and evaluation of tests, directly contact the recruiter of the concerned company.

What happens if I am locked out of my account during a Test?

If you log out or are unintentionally locked out of your account during a test before submitting your code, the same can have the following implications:

  • If the test is timed, logging out of the account before clicking Submit leads to auto-submission of the latest code on the candidate's editor.
  • Logging out of your account during a test means your test attempt will automatically come to an end.
  • If you wish to retake the test, contact the recruiter who invited you to the test directly and request a re-invite.
  • You retake a test only if you are re-invited for the test.

After I have submitted an answer to a question can I come back and change my submission?

Yes. You can navigate freely across the questions and resubmit your solution to any question accessible by clicking on "Submit & Continue" multiple times. Please note that some tests have timed sections, and once a section-time limit is reached, you will not be able to revisit questions in that section. But there is no limit on the number of times you can submit your answer to a question that you can view/edit.

What if I encounter technical issues during a Test?

We recommend you go through our Frequently Asked Questions for any technical-related issues. 

You can also refer to Candidate Support , where we host many support articles for candidates.

If your queries are not resolved using the available documents or have persistent issues, please get in touch with our support team here.

FAQ related to Errors 

Why am i seeing the error "the hackerrank test platform is at capacity".

The HackerRank for Work test platform allows different candidates to simultaneously log in and attempt their respective tests. Our platform may sometimes experience an unprecedented volume of candidates taking different tests simultaneously.

To ensure a good test experience, the platform has a particular limit on the number of candidates allowed to attempt HackerRank tests at a given instant. In a scenario where the specified limit of test-takers has exceeded the platform, a candidate may not log in to a test.

TCS_screenshot.png

This is usually a temporary situation. We recommend:

  • You try again after some time -  provided  there is   sufficient time left in the test schedule. You should be able to log in and start your test when the situation eases on the platform.
  • Contact your hiring manager - if the test schedule ends soon and you are running short of time.
  • Contact the recruiter or the hiring company who originally sent you the test invitation and inform them about the situation.

Reply_All.jpg

Why are Questions and images not visible in my Test?

You can resolve this problem by performing any of the following:

  • Refresh your browser tab or window. If a page is refreshed while the test is in progress, it does not affect the test workflow. After the page is refreshed, you return to the same question you were solving. All the previous submissions are retained.
  • You can open your session in incognito mode.
  • You can empty the cache and cookies to resolve this problem.
  • You can log out of the current session and log in again. All the previous submissions are retained in this case.

What can I do when a question does not load properly and I cannot see all images or widgets on the question page?

If you are experiencing slow net speeds, some page components may not load. Such issues are generally solved by refreshing your browser tab/window. Refreshing your browser tab while taking a test will not affect your flow. You will be brought back to exactly where you were, and you can continue solving problems.

FAQ Related to Programming Tests

How to choose a programming language in a test.

In the HackerRank Coding tests, the   languages   option available in the editor lists the different programming languages you can choose from to write your solution. The editor automatically resets and adapts according to the chosen language.

Pointing_the_language_option.jpg

How to view and copy the original code?

In your tests, for coding questions, you can reuse the initial or original prototypical code, which was populated in the editor for the selected programming language. You can reset your code by simply copying and pasting the original version over your version of the code.

hackerrank problem solving questions

  • You can copy/paste lines using Ctrl/Command + C 

hackerrank problem solving questions

  • The changes you make to the Modified Code will reflect in your editor once you click " Update .".

Note : The code editor periodically saves your code. The editor automatically resets when you choose a different programming language.

What are Test Cases?

In your Coding questions, test cases are the different types of inputs to your code to test your defined logic and produce the output. A test case is termed "passed" when the output from your code exactly matches the expected output. Otherwise, the " Wrong Answe r" status is indicated against the test case.

Refer to the following topics for detailed information about test Cases:

  • Test Cases in your Coding Question
  • Sample Test Cases
  • Hidden Test Cases
  • Failed Test Cases and Wrong Answer Status

How can I test my code?

  • Click Run code to compile your logic and execute all the test cases in the code editor. You can click this button any number of times during a test.
  • If permitted in your test, use the "t est against custom input " option to validate your logic using your own input values.

Note: When you use the keyboard shortcut command+return to Run Code , the cursor will automatically move to the next line in the code editor. Also, Clicking Run Code does not calculate any scores for the test cases.

See Debug using custom inputs .

why is that sample test cases passed but others are failing?

Sample test cases are simple validation scenarios to test your logic, whereas the other test cases may cover corner scenarios around the problem. Try to understand the constraints in the problem statement and verify the coding or logical approach in your solution to handle different edge scenarios around the problem. Maybe you're solving a different problem than the question expects you to solve.

Why is the output hidden for a few Test cases?

These are called "Hidden test cases" and validate your code to cover edge scenarios for the given problem. Through hidden test cases, test setters expect to understand candidates' problem-solving abilities, and therefore, the input and output values are hidden. Candidates are expected to think through the various scenarios around a problem and produce the expected output in test cases.

See Hidden test cases .

My code works on my local editor but fails on HackerRank. What is the cause?

If your code works on the local editor but fails on HackerRank, The reason could be one from the below:

  • Your code doesn't match the expected output .  The output produced by your code must exactly match the output expected by the test case, so something like a spelling error in your output will cause you to fail the challenge.
  • You're using a different compiler .  Check out our  Environment page for up-to-date information on how we're compiling your code.
  • Your code's behavior is unpredictable . If you're using C/C++, double-check for uninitialized variables or invalid memory accesses, as they can cause unpredictable behavior. If you overrun an array or attempt to print the contents of an array cell that was never initialized, your output may look like it's correct, but you'll fail the challenge (invisible garbage characters are the worst, we know).

Does your editor have Intellisense like autocomplete?

Yes, we have intelligent auto-complete similar to what is found in modern editors such as Eclipse or Visual Studio. Auto-complete will automatically trigger in languages like Java and Python at specific syntax points - like after you type "." in "System.out." You can also trigger it manually at any time using the "Ctrl-Space" key combination.

Can my code write to a file?

Check out the  Writing State Information to a File article in our knowledge base.

What is the difference between "Run Code" and "Submit code"?

In your HackerRank tests, coding questions have an in-built editor (IDE) and compiler which supports coding in multiple programming languages. When you are solving coding questions, the editor automatically saves your code periodically and also has the following options:

  • Run code - Click this button any number of times to compile your code and run test cases.  The option first checks for any coding errors and then validates test cases by comparing the output from your code against the expected output. While debugging or after making any code changes, click " Run code " to recompile and retest your solution.

Clicking " Run code " does not evaluate your answer or calculate any scores for the test cases.

  • Submit code and Continue  - Click to  Submit your final answer to a coding problem. You can modify a submission and resubmit your answer any number of times before the test ends. Scores are calculated for the submitted version of your answer in the test.

Note : If your test times out before submitting the final answer, the last compiled version of your code is automatically submitted in the test. Click   here   for more information.

Run_and_Submit.jpg

Why I am seeing "Terminated due to timeout" status when I run my code?

In the HackerRank coding environment, your coding solution has an execution time limit depending on the chosen programming language. When you run your code, this is the time limit within which your code is expected to read input, process, and return output for all the test cases, failing which, you will see the " Terminated due to timeout " message.

Refer to the   HackerRank Coding Environment Specifications Page  to know the specific time limit for your chosen programming language, and accordingly, optimize your code for faster execution to achieve the output. 

Your test setter expects optimal solutions in coding questions, and therefore, on the HackerRank coding environment, there are preset execution time limits for different programming languages. For example, the   Python   language has a 10-second time limit as compared to the   C language,   which has a 2-second execution time limit.

For a detailed understanding, refer to The "Terminated due to timeout" status topic.

How to view or download the sample input and output values?

In your HackerRank tests, for coding questions, you can download the sample input and output values for reference by clicking the   Download sample test cases   link as shown below.

Link_to_download_sample_test_cases.jpg

The input and output values are downloaded in separate text files, and each contains the values defined in the   Sample test cases   of the coding question.

The input values are downloaded in   raw format . For example, if the input values are array elements, then the input file will contain the array size followed by the array elements as input.

raw_format_values.jpg

Refer to the  Custom input values format  topic for detailed information.

  Note : You can only download the sample input and output values if your test setter has defined   Sample test cases   for the coding question.

My Java/C#/Scala code works in my IDE, but why does it fail in the Test interface?

If you are using Java, C#, or Scala, you have to call your main class Solution . This is essential to get your code to run. Please do not use any package names in your code.

What are the possible causes for a "Wrong Answer"?

A " Wrong Answer " status in your HackerRank Coding questions implies that your program or code is unable to produce the exact expected output for the Test Cases.

Some common causes of a " Wrong Answer " are listed below:

  • A mismatch between the format of your output and the format of the expected output.
  • Your solution's inability to handle corner scenarios and provide a complete solution.
  • Code formatting and naming guidelines issue.
  • Debug output values printed in the " Your Output " area and compared with the expected output.

Refer to the   Failed Test Cases or "Wrong Answer" Status  topic for detailed information.

It is recommen ded that you verify your solution for any of the above-mentioned causes and   debug your code   to   identify logical issues.

How can I debug and test my code?

In HackerRank Tests, you can debug your solution using the following methods:

  • Using the   "Test against custom input" option   to pass custom input values to your code and verifying the output.
  • Using the relevant   debug print statements or print commands   specific to the chosen programming language. Include the print commands and test your outputs at different logical levels. For example, while coding with   C++ , use the   c out<<   command to debug your code.

Refer to the following topics for specific information:

  • Debugging a complete program
  • Debugging your logic in Functions
  • Debug Using Custom Input
  • Failed Test Cases or "Wrong Answer" Status

How do I read from STDIN and write to STDOUT in various languages?

In most problems, you would read input from STDIN (Standard Input) and write output to STDOUT (Standard Output). Different languages have different methods of accessing STDIN and STDOUT . Please refer to the sample codes below for the most common (possibly naive) methods.

This is best explained with a simple problem statement and solutions in different languages.

Problem Statement

Write a program that adds two numbers prints the sum to STDOUT. Read the input from STDIN. The first line of your input will contain an integer (N) that tells you how many more lines there are in the input. Each of the subsequent N lines contains 2 integers). You need to print the sum of each pair on a separate line of STDOUT.

Sample Input

Sample Output

Objective C

Where can I get answers for my IDE related queries on Front-end, Back-end or Full-stack based assessments?

See Front-end, Back-end, Full-stack IDE - FAQs for technical queries related to Front-end, Back-end, or Full-stack assessments.

Related articles

  • Frequently Asked Questions After the Test
  • Frequently Asked Questions Before the Test
  • Front-end, Back-end, Full-stack Assessments - FAQs
  • Execution Environment
  • Answering Coding Questions

Revising the Select Query I Easy SQL (Basic) Max Score: 10 Success Rate: 95.94%

Revising the select query ii easy sql (basic) max score: 10 success rate: 98.69%, select all easy sql (basic) max score: 10 success rate: 99.54%, select by id easy sql (basic) max score: 10 success rate: 99.66%, japanese cities' attributes easy sql (basic) max score: 10 success rate: 99.59%, japanese cities' names easy sql (basic) max score: 10 success rate: 99.52%, weather observation station 1 easy sql (basic) max score: 15 success rate: 99.42%, weather observation station 3 easy sql (basic) max score: 10 success rate: 98.03%, weather observation station 4 easy sql (basic) max score: 10 success rate: 98.71%, weather observation station 5 easy sql (intermediate) max score: 30 success rate: 94.42%, cookie support is required to access hackerrank.

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

Coding Made Simple

HackerRank Solutions in Python

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

hackerrank problem solving questions

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.

Python HackerRank Solutions

  • Say “Hello, World!” With Python – Hacker Rank Solution
  • Python If-Else – Hacker Rank Solution
  • Arithmetic Operators – Hacker Rank Solution
  • Python: Division – Hacker Rank Solution
  • Loops – Hacker Rank Solution
  • Write a Function – Hacker Rank Solution
  • Print Function – Hacker Rank Solution
  • List Comprehensions – Hacker Rank Solution
  • Find the Runner-Up Score! – Hacker Rank Solution
  • Nested Lists – Hacker Rank Solution
  • Finding the Percentage – Hacker Rank Solution
  • Lists – Hacker Rank Solution
  • Tuples – Hacker Rank Solution
  • sWAP cASE – Hacker Rank Solution
  • String Split and Join – Hacker Rank Solution
  • What’s Your Name? – Hacker Rank Solution
  • Mutations – Hacker Rank Solution
  • Find a String – Hacker Rank Solution
  • String Validators – Hacker Rank Solution
  • Text Alignment – Hacker Rank Solution
  • Text Wrap – Hacker Rank Solution
  • Designer Door Mat – Hacker Rank Solution
  • String Formatting – Hacker Rank Solution
  • Alphabet Rangoli – Hacker Rank Solution
  • Capitalize! – Hacker Rank Solution
  • The Minion Game – Hacker Rank Solution
  • Merge the Tools! – Hacker Rank Solution
  • Itertools.Product() – Hacker Rank Solution
  • Collections.Counter() – Hacker Rank Solution
  • Itertools.Permutations() – Hacker Rank Solution
  • Polar Coordinates – Hacker Rank Solution
  • Introduction to Sets – Hacker Rank Solution
  • DefaultDict Tutorial – Hacker Rank Solution
  • Calendar Module – Hacker Rank Solution
  • Exceptions – Hacker Rank Solution
  • Collections.namedtuple() – Hacker Rank Solution
  • Time Delta – Hacker Rank Solution
  • Find Angle MBC – Hacker Rank Solution
  • No Idea! – Hacker Rank Solution
  • Collections.OrderedDict() – Hacker Rank Solution
  • Symmetric Difference – Hacker Rank Solution
  • Itertools.Combinations() – Hacker Rank Solution
  • Incorrect Regex – Hacker Rank Solution
  • Set.add() – Hacker Rank Solution
  • Itertools.combinations_with_replacement() – Hacker Rank Solution
  • Word Order – Hacker Rank Solution
  • Set.discard(), .remove() & .pop() – Hacker Rank Solution
  • Collections.deque() – Hacker Rank Solution
  • Compress the String! – Hacker Rank Solution
  • Company Logo – Hacker Rank Solution
  • Set.union() Operation – Hacker Rank Solution
  • Piling Up! – Hacker Rank Solution
  • Triangle Quest 2 – Hacker Rank Solution
  • Iterables and Iterators – Hacker Rank Solution
  • Set.intersection() Operation – Hacker Rank Solution
  • Mod Divmod – Hacker Rank Solution
  • Power – Mod Power – Hacker Rank Solution
  • Maximize It! – Hacker Rank Solution
  • Set.difference() Operation – Hacker Rank Solution
  • Integers Come in All Sizes – Hacker Rank Solution
  • Set.symmetric_difference() Operation – Hacker Rank Solution
  • Set Mutations – Hacker Rank Solution
  • Triangle Quest – Hacker Rank Solution
  • The Captain’s Room – Hacker Rank Solution
  • Check Subset – Hacker Rank Solution
  • Check Strict Superset – Hacker Rank Solution
  • Classes: Dealing With Complex Numbers – Hacker Rank Solution
  • Class 2 – Find the Torsional Angle – Hacker Rank Solution
  • Zipped! – Hacker Rank Solution
  • Input() – Hacker Rank Solution
  • Python Evaluation – Hacker Rank Solution
  • Athlete Sort – Hacker Rank Solution
  • Any or All – Hacker Rank Solution
  • ginorts – Hacker Rank Solution
  • Detect Floating Point Number – Hacker Rank Solution
  • Map and Lambda Function – Hacker Rank Solution
  • Re.split() – Hacker Rank Solution
  • Validating Email Addresses With a Filter – Hacker Rank Solution
  • Group(), Groups() & Groupdict() – Hacker Rank Solution
  • Reduce Function – Hacker Rank Solution
  • Re.findall() & Re.finditer() – Hacker Rank Solution
  • Re.start() & Re.end() – Hacker Rank Solution
  • Regex Substitution – Hacker Rank Solution
  • Validating Roman Numerals – Hacker Rank Solution
  • Validating Phone Numbers – Hacker Rank Solution
  • Validating and Parsing Email Address – Hacker Rank Solution
  • Hex Color Code – Hacker Rank Solution
  • HTML Parser – Part 1 – Hacker Rank Solution
  • HTML Parser – Part 2 – Hacker Rank Solution
  • Detect HTML Tags, Attributes and Attribute Values
  • XML 1 – Find the Score – Hacker Rank Solution
  • Validating UID – Hacker Rank Solution
  • Validating Credit Card Numbers – Hacker Rank Solution
  • XML2 – Find the Maximum Depth – Hacker Rank Solution
  • Standardize Mobile Number Using Decorators – Hacker Rank Solution
  • Validating Postal Codes – Hacker Rank Solution
  • Decorators 2 – Name Directory – Hacker Rank Solution
  • Matrix Script – Hacker Rank Solution
  • Words Score – Hacker Rank Solution
  • Arrays – Hacker Rank Solution
  • Shape and Reshape – Hacker Rank Solution
  • Default Arguments – Hacker Rank Solution
  • Transpose and Flatten – Hacker Rank Solution
  • Concatenate – Hacker Rank Solution
  • Zeros and Ones – Hacker Rank Solution
  • Eye and Identity – Hacker Rank Solution
  • Array Mathematics – Hacker Rank Solution
  • Floor, Ceil and Rint – Hacker Rank Solution
  • Sum and Prod – Hacker Rank Solution
  • Min and Max – Hacker Rank Solution
  • Mean, Var and Std – Hacker Rank Solution
  • Dot and Cross – Hacker Rank Solution
  • Inner and Outer – Hacker Rank Solution
  • Polynomials – Hacker Rank Solution
  • Linear Algebra – Hacker Rank Solution

Best Online Calculators

Disclaimer: The above Python Problems are generated by Hacker Rank but the Solutions are Provided by CodingBroz . These tutorials are only for Educational and Learning Purpose.

  • HackerRank C Solutions
  • HackerRank C++ Solutions
  • HackerRank SQL Solution

1 thought on “HackerRank Solutions in Python”

' src=

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.

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

solution.py

Latest commit, file metadata and controls.

IMAGES

  1. 9. How to solve problems on HackerRank

    hackerrank problem solving questions

  2. How To Solve Questions On Hackerrank| How To Solve Problems On Hackerrank|Hackerrank Problem Solving

    hackerrank problem solving questions

  3. Hackerrank Problem Solving (Basic)

    hackerrank problem solving questions

  4. 02

    hackerrank problem solving questions

  5. 6 Problem-Solving HackerRank Questions and Answers for Your Interview

    hackerrank problem solving questions

  6. HackerRank Problem Solving(Basic) Solutions [4 Questions Solved] With Certificate

    hackerrank problem solving questions

COMMENTS

  1. Problem solving

    Solve N problems with increasing difficulty and variety in the least number of days. See the problem statement, constraints, sample input and output, and code submission options.

  2. 15 Common Problem-Solving Interview Questions

    Learn how to test candidates' problem-solving skills with technical and non-technical questions. Find examples of coding challenges, STAR, SOAR and PREP methods, and tips to customize questions for your company.

  3. Solve Python

    Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. ... Problem Solving (Basic) Python (Basic) Problem Solving (Advanced) Python (Intermediate) Difficulty. Easy. Medium. Hard. Subdomains. Introduction. Basic Data Types. Strings. Sets. Math. Itertools. Collections ...

  4. Solutions to Hackerrank practice problems

    170+ solutions to Hackerrank.com practice problems using Python 3, С++ and Oracle SQL - marinskiy/HackerrankPractice

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

    Add this topic to your repo. To associate your repository with the hackerrank-problem-solving 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.

  6. Solutions to Certification of Problem Solving Basic on Hackerrank

    Hackerrank Problem Solving(Basic) Certificate test soltions. 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)

  7. 6 Problem-Solving HackerRank Questions and Answers for Your Interview

    Let's go through 6 problem-solving HackerRank sample questions and answers that can help you perform better in interviews. Commonly Asked HackerRank Questions and Their Answers. HackerRank interviews have both technical and non-technical questions to evaluate a candidate. Since the people who cleared the coding challenges meet the criteria ...

  8. Answering Coding Questions

    The HackerRank Test platform supports assessments in multiple programming languages with an intuitive and in-built code editor to help you solve coding challenges. Coding questions may require you to complete the logic of a given function, and the remaining portions of a program may be non-editable. Alternatively, some questions may require you ...

  9. ALL HackerRank Solutions

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

  10. What I Learned in Obtaining a Problem Solving (Basic) Hackerrank

    There are problem-solving questions that we can solve within 1 month. It is divided into 4 weeks where each week has around 12-16 practice questions and 1 mock test question.

  11. Solve Algorithms

    Easy Problem Solving (Basic) Max Score: 10 Success Rate: 94.54%. Solve Challenge. Compare the Triplets. ... Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to ...

  12. Top 25 Hackerrank Coding Questions with Solutions

    Prepare for Hackerrank coding test with these 25 practice questions from various topics and difficulty levels. Learn how to solve problems related to taxi drivers, street lights, jobs, and more with C++, Java, and Python solutions.

  13. Hackerrank

    Hackerrank Problem Solving Solution Tutorial playlist in python Solving data structure and algorithm problems in python with understandable approach. These p...

  14. HackerRank SQL Problem Solving Questions With Solutions

    Post displaying HackerRank sql problem solving questions and solution. Articles Works Shiny Snippets Resume About Contact. Guestbook. Open main menu. Published on November 5, 2020. 8223 words 42 min read --- views. HackerRank SQL Problem Solving Questions With Solutions # Related Topics:

  15. hackerrank-solutions · GitHub Topics · GitHub

    HackerRank's programming challenges can be solved in a variety of programming languages (including Java, C++, PHP, Python, SQL, JavaScript) and span multiple computer science domains. When a programmer submits a solution to a programming challenge, their submission is scored on the accuracy of their output.

  16. Problem Solving (Basic) Skills Certification Test

    Problem Solving Concepts. It covers basic topics of Data Structures (such as Arrays, Strings) and Algorithms (such as Sorting and Searching). Do you have more questions? Check out our FAQ. Take the HackerRank Skills Test. Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming ...

  17. HackerRank Java solutions

    Explore comprehensive Java solutions for HackerRank challenges. Enhance your coding skills with detailed explanations and code snippets, empowering you to conquer diverse programming problems and excel in Java development. Access a curated repository to strengthen your problem-solving abilities and advance your understanding of Java programming on HackerRank

  18. Answering Database programming Questions

    Steps. In your Test, select the Database Engineer question or click Solve. A DB engineering question in HackerRank Test. Read the problem statement carefully and refer to the given data schema, if any. Understanding the question's problem statement and the data schema. In the code editor, choose the DB language.

  19. Frequently Asked Questions During the Test

    Through hidden test cases, test setters expect to understand candidates' problem-solving abilities, and therefore, the input and output values are hidden. ... In your HackerRank tests, coding questions have an in-built editor (IDE) and compiler which supports coding in multiple programming languages. When you are solving coding questions, the ...

  20. 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.

  21. Solve SQL

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

  22. HackerRank Solutions in Python

    Mean, Var and Std - Hacker Rank Solution. Dot and Cross - Hacker Rank Solution. Inner and Outer - Hacker Rank Solution. Polynomials - Hacker Rank Solution. Linear Algebra - Hacker Rank Solution. Disclaimer: The above Python Problems are generated by Hacker Rank but the Solutions are Provided by CodingBroz.

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

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window.