Red Hat Coding Questions with Answers

Red Hat Coding Questions With Solutions

Red Hat Coding Questions and Answers page will help you to prepare yourself to appear for recruitment drives for the designation of Software Engineer and Software Engineer Intern in Red Hat.

The page is mainly focused on the Insights on Steps of recruitment process of the company and what are the preferences of the company’s recruitment team to hire the candidate.

red-hat-coding-questions

About Red Hat

Red Hat is a software company known for its enterprise open-source solutions. Founded in 1993, Red Hat has become a prominent player in the world of Linux-based operating systems and has expanded its offerings to encompass a wide range of enterprise software and services. In 2019, Red Hat was acquired by IBM, further bolstering its capabilities and market reach.
They mainly work on – open-source projects, Red Hat Enterprise Linux (RHEL), OpenShift, and Red Hat JBoss Enterprise Application Platform (JBoss EAP), a Java-based application server for building and deploying enterprise applications.

About Red Hat Hiring Process

Here we have mentioned everything regarding the Red Hat Recruitment Process. Going through each process is mandatory and every round is an elimination round.

  • Round 1: Online Coding Test
  • Round 2: Technical Interview – 1
  • Round 3: Technical Interview – 2
  • Round 4: HR Interview
Here we have mentioned some significant details of Red Hat hiring process in following tabular form:
Red HatRelated Information
Position :
  • Software Engineer Intern
Course :
  • B.E / B.Tech – CSE & IT or MCA
  • Eligible Batch – 2023
Eligibility Criteria / Academic Qualification Required :
  • No Minimum Score is required in 10th / 12th/ Graduation / Post Graduation.
  • No Current Backlogs
Cost to Company (CTC)₹ 12 – 13 L.P.A
Selection Process :
  1. Online Coding Assessment
  2. 2 Rounds of Technical Interviews
  3. HR Interview
Joining Location :Remote

Prime Course Trailer

Related Banners

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

Sample Red Hat Coding Questions with Solutions

Question : 1

Problem Statement –  Abhijeet is one of those students who tries to get his own money by part time jobs in various places to fill up the expenses for buying books. He is not placed in one place, so what he does, he tries to allocate how much the book he needs will cost, and then work to earn that much money only. He works and then buys the book respectively. Sometimes he gets more money than he needs so the money is saved for the next book. Sometimes he doesn’t. In that time, if he has stored money from previous books, he can afford it, otherwise he needs money from his parents.

Now His parents go to work and he can’t contact them amid a day. You are his friend, and you have to find how much money minimum he can borrow from his parents so that he can buy all the books.

He can Buy the book in any order.

Function Description:

Complete the function with the following parameters:

NameTypeDescription
NIntegerHow many Books he has to buy that day.
EarnArray[ ]Integer arrayArray of his earnings for the ith book
CostArray[ ]Integer arrayArray of the actual cost of the ith book.

Constraints:

  • 1 <= N <= 10^3
  • 1 <= EarnArray[i] <= 10^3
  • 1 <=  CostArray[i] <= 10^3

Input Format:

  • First line contains N.
  • Second N lines contain The ith earning for the ith book.
  • After that N lines contain The cost of the ith book.

Output Format: The minimum money he needs to cover the total expense.

Sample Input 1:

3

[3 4 2]

[5 3 4]

Sample Output 1:

3

Explanation:

At first he buys the 2nd book, which costs 3 rupees, so he saves 1 rupee. Then he buys the 1st book, that takes 2 rupees more. So he spends his stored 1 rupee and hence he needs 1 rupee more. Then he buys the last book.

Question : 2

Problem Description

Question:- Krishna loves candies a lot, so whenever he gets them, he stores them so that he can eat them later whenever he wants to.

He has recently received N boxes of candies each containing Ci candies where Ci represents the total number of candies in the ith box. Krishna wants to store them in a single box. The only constraint is that he can choose any two boxes and store their joint contents in an empty box only. Assume that there are an infinite number of empty boxes available.

At a time he can pick up any two boxes for transferring and if both the boxes contain X and Y number of candies respectively, then it takes him exactly X+Y seconds of time. As he is too eager to collect all of them he has approached you to tell him the minimum time in which all the candies can be collected.

Input Format:

  • The first line of input is the number of test case T
  • Each test case is comprised of two inputs
  • The first input of a test case is the number of boxes N
  • The second input is N integers delimited by whitespace denoting the number of candies in each box

Output Format: Print minimum time required, in seconds, for each of the test cases. Print each output on a new line.

Constraints:

  • 1 < T < 10
  • 1 < N< 10000
  • 1 < [Candies in each box] < 100009
S. No.InputOutput
11
4
1 2 3 4
19
21
5
1 2 3 4 5
34

Explanation for sample input-output 1:

4 boxes, each containing 1, 2, 3 and 4 candies respectively.Adding 1 + 2 in a new box takes 3 seconds.Adding 3 + 3 in a new box takes 6 seconds.Adding 4 + 6 in a new box takes 10 seconds.Hence total time taken is 19 seconds. There could be other combinations also, but overall time does not go below 19 seconds.

Explanation for sample input-output 2:

5 boxes, each containing 1, 2, 3, 4 and 5 candies respectively.Adding 1 + 2 in a new box takes 3 seconds.Adding 3 + 3 in a new box takes 6 seconds.Adding 4 + 6 in a new box takes 10 seconds.Adding 5 + 10 in a new box takes 15 seconds.Hence total time taken is 34 seconds. There could be other combinations also, but overall time does not go below 33 seconds.

Question : 3

Rahul has an array a, consisting of n integers a1, a2, …, an. The boy cannot sit and do nothing, he decided to study an array. Rahul took a piece of paper and wrote out m integers l1, l2, …, lm (1 ≤ li ≤ n). For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, …, n. Formally, he want to find the number of distinct numbers among ali, ali + 1, …, an.?

Rahul wrote out the necessary array elements but the array was so large and the boy was so pressed for time. Help him, find the answer for the described question for each li.

Input

  • The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, …, an (1 ≤ ai ≤ 105) — the array elements.
  • Next m lines contain integers l1, l2, …, lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output

  • Print m lines — on the i-th line print the answer to the number li.

Examples

  • Input
    10 10
    1 2 3 4 1 2 3 4 100000 99999
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
  • Output
    6
    6
    6
    6
    6
    5
    4
    3
    2
    1

Question : 4

You just received another bill which you cannot pay because you lack the money.

Unfortunately, this is not the first time to happen, and now you decide to investigate the cause of your constant monetary shortness. The reason is quite obvious: the lion’s share of your money routinely disappears at the entrance of party localities.

You make up your mind to solve the problem where it arises, namely at the parties themselves. You introduce a limit for your party budget and try to have the most possible fun with regard to this limit.

You inquire beforehand about the entrance fee to each party and estimate how much fun you might have there. The list is readily compiled, but how do you actually pick the parties that give you the most fun and do not exceed your budget?

Write a program which finds this optimal set of parties that offer the most fun. Keep in mind that your budget need not necessarily be reached exactly. Achieve the highest possible fun level, and do not spend more money than is absolutely necessary.

Input

  • The first line of the input specifies your party budget and the number n of parties.
  • The following n lines contain two numbers each. The first number indicates the entrance fee of each party. Parties cost between 5 and 25 francs. The second number indicates the amount of fun of each party, given as an integer number ranging from 0 to 10.
  • The budget will not exceed 500 and there will be at most 100 parties. All numbers are separated by a single space.
  • There are many test cases. Input ends with 0 0.

Output

  • For each test case your program must output the sum of the entrance fees and the sum of all fun values of an optimal solution. Both numbers must be separated by a single space.

Example

  • Sample input:
    50 10
    12 3
    5 8
    16 9
    16 6
    10 2
    21 9
    18 4
    12 4
    17 8
    18 9
    50 10
    13 8
    19 10
    16 8
    12 9
    10 2
    12 8
    13 5
    15 5
    11 7
    16 2
    0 0
  • Sample output:
    50 29
    48 32

Question : 5

Ajay has a flight to catch in an hour. So he has to reach the airport as fast at possible. He hires a taxi and promises the taxi driver that if he reaches the airport within k minutes he would pay the taxi driver double the amount.

The city description is as follows –

The taxi is at point 0,0  & airport is at (n-1,m-1) in a 2 – D grid of n rows and m columns. The grid has some blocked (represented as’#’) and some unblocked (represented as’.’) cells. 

The starting position of the taxi is in the top – left corner of the grid. It is guaranteed that the starting position & ending positions are not blocked. Each cell of the grid is connected with its right ,left,top,bottom cells (if those cells exist ). It takes 1 second for a taxi to move from a cell to its adjacent cell. 

If the taxi can reach the bottom-right (airport) corner of the grid within  k seconds, return the string ‘Yes’. Otherwise , return the string ‘No’.

Example 

rows =3

grid =[‘..##’,’#.##’,’#…’]

maxTime =5

..##

#.##

#…

It will take the taxi 5 seconds to reach the bottom right corner. As long as k>_5,return

‘Yes’.

Returns:

String;the final string; either ‘yes’ or ‘ No’

Constraints 

  • 1<_rows<_500
  • 0<_maxTime<_10^6

Input Format For Custom Testing

  • The first line contains an integer,rows that denotes the number of rows of the 2-D grid
  •  In each of the next rows lines, the i^th line contains a string denoting the configuration of the i^th row of the grid.
  • The last line contains an integer, maxTime ,that represents the maximum time in seconds the taxi has to reach the bottom right cell.

Example

  • Sample Input 0
    2 -> size of grid[] rows =2
    .. -> grid = [‘..’,’..’]
    ..
    3 -> maxTime = 3
  • Sample Output 0
    Yes

Explanation

The grid has 2 rows and 2 columns and the time within which the taxi needs to reach the bottom-right cell in 3 seconds. Starting from the top-left cell, the taxi can either move to the top-right unblocked 

FAQs on Red Hat Coding Questions

Question 1: How many rounds are there in Red Hat Hiring Process?

There are in total three rounds in the Red Hat Hiring Process which includes:-

  1. Coding Assessments
  2. Technical Interview
  3. HR Interview
Question 2: Is Coding questions asked in Red Hat Recruitment Process?

Yes, Coding Questions are included in Online Assessment and Technical Interview of Red Hat.

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

Checkout list of all the video courses in PrepInsta Prime Subscription