Consultadd Coding Questions and Answers

Sample Consultadd Coding Questions with Solutions

On this page, you will get Sample Consultadd Coding Questions and Answers, which were asked in Online Coding Test and Technical Interviews included in Consultadd Recruitment Process.

Apart from that you will get Faq’s related to Condultadd Recruitment process including Salary Offered, Eligibility Criteria, and Job Profile and many more.

consultadd-coding-questions

Sample Consultadd Coding Questions with Solutions - Set 1

Question 1: Match

Problem Statement :
The number of goals achieved by two football teams in matches in a league is given in the form of two lists. For each match of team B. Compute the total number of matches of team A where team A has scored less than or equal to the number of goals scored by team B in that match.

Example : 
team A =[ 1,2,3]
team B =[ 2,4]
Team A has played three matches and has scored team A =[1,2,3] goals in each match respectively. Team B has played two matches and has scored team B = [2,4] goals in each match respectively. For 2 goals scored by team B in its first match, team A has 2 matches with scores 1,2 and 3 hence , the answer is [2,3].

Function Description :

Complete the function counts in the editor below.

Counts has the following parameters:
int teamA(n): First array of positive integers
int teamB(m): Second array of positive integers

Return :
int(m): an array of m positive integers, one for each teamB[i] representing the total number of elements from teamA[j] satisfying teamA[j]<_ teamB[i] where 0<_j<n and 0<_i< m, in the given order.

Constraints :
2<_n, m<_10^5
1<_ teamA[j]<_10^9,where 0<_j<n.
1<_ teamB[i]<_10^9,where 0<_j<m

Input format for custom Testing :
Input from stdin will be processed as follows and passed to the functions.

The first line contains an integer n, the number of elements in teamA.
The next n lines each contain an integer describing teamA[j] where 0<_j<n.
The next line contains an integer m, the number of elements in teamB.
The next m lines each contain an integer describing teamB[i]where 0<_i<m.

Sample input 0 :
4 -> teamA[] size n = 4
1 -> teamA = [1,4,2,4]
4
2
4
2-> teamB [] size m = 2
3-> teamB = [3,5]
5

Sample ōutput 0 :
2
4

Explanation 0 :
Given values are n =4, team A = [1,4,2,4], m= 2, and teamB = [3,5].
For teamB[0] = 3, we have 2 elements in teamA(teamA[0] = 1 and teamA[2] = 2) that are <_ teamB[0].
For teamB[1] = 5, we have 4 elements in teamA(teamA[0] = 1, teams[1] =4, teamA[2] = 2, and teamA[3] =4) that are <_teamB[1].
Thus , the function returns the array [2,4] as the answer.

Prime Course Trailer

Related Banners

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

Question 2 : Share Holder (R -> Hard)

Problem statement :

Ratan is a crazy rich person. And he is blessed with luck, so he always made the best profit possible with the shares he bought. That means he bought a share at a low price and sold it at a high price to maximize his profit. Now you are an income tax officer and you need to calculate the profit he made with the given values of stock prices each day. You have to calculate only the maximum profit Ratan earned.
Note that:
Ratan never goes into loss.

Example 1 :

Price=[1,6,2]
Ratan buys it on the first day and sells it on the second.

Example 2 :

Price=[9,8,6]

The Price always went down, Ratan never bought it.

Input Format:
First line with an integer n, denoting the number days with the value of the stack
Next n days, telling the price of the stock on that very day.

Output Format:
Maximum profit done by Ratan in a single line.
Constraints:
Number of days <=10^8

Sample Input for Custom Testing

STDIN
———–
7
1
9
2
11
1
9
2

Sample Output

10

Explanation

The maximum profit possible is when Ratan buys it in 1 rupees and sells it in 11.

Question 3: Formatting large Products

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

Constraints

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

Sample Input 0 

1

5

Sample Output 0

12 * 10^1

Explanation 

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

Sample Input 1

3

10

Sample Output 1

18144 * 10^2

Explanation

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

Question 04 : 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 5 : Coin Game (R->Medium)

Problem Statement  :

Raman was playing a game, he starts with x coins. Now in every step, he wins and loses and he has to get the money or pay the money as needed. He came in contact with a psychic who can see the future and the Psychic predicted the outcomes after each step. Now Raman wants to start the game with the minimum wage where he doesn’t run out of money. Help Raman to find what money he should start with. The only rule to keep playing is not going in a credit situation.

Input Format:

First line with n, number of steps in the game
Next n lines, n integers denoting outcomes of every game. Positive means winning and negative means losing that money.

Output Format:

One single integer denoting the minimum amount to start with

Constraints:

Number of steps<=10^9
-1000<=Money needed in each step<=1000

Sample Input:

4
2
-9
15
2

Sample Output:

7

Explanation:

If he starts with 7 rupees, then after steps : 7 ->9 -> 0-> 15 -> 17.

Sample Consultadd Coding Questions with Solutions - Set 2

Question 1: Seating Arrangement in Exam Hall

Problem Statement  :

Semester exams are going on for university students. Examiners noticed that a group of people are trying to cheat. They marked students of that group as ‘1’ and students of another group ( who are not cheating ) as ‘0’ 

We can reduce cheating by not allowing students from group 1 to sit together, means no two students from group 1 can sit together. Seatings are marked using above conditions. Your task is to give the seating placement of nth possibility Possibility order from 1 to 10 is given below

[1  10  100  101  1000  1001  1010  10000  10001  10010]

Sample input :

3 → number of test cases

4

6

9

Sample output :

101

1001

10001

Explanation :

4th possibility is 101 

6th possibility is 1001

9th possibility is 10001

Question 2: Stepping Numbers

Problem Description :

Stepping Numbers are numbers in which the adjacent digits differ by 1. For example, 123, 545, and 98 are stepping numbers, while 321, 444, and 75 are not. The task is to find all stepping numbers in a given range [n, m].

  • For example
    • Range: [100, 500]
    • Stepping Numbers: 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, 345
    • Explanation: The stepping numbers between 100 and 500 are 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, and 345. These numbers have adjacent digits that differ by 1.

Write code to find out all the stepping numbers in the given range.

Input Format: First line contains two numbers N,M

Output Format: Print all the stepping numbers present in the range.

Constraints: 0 <= N < M <= 1,000,000,000

Question 3: Sort array after converting elements to their squares

Problem Description :

You are given an array of integers in non-decreasing order. Your task is to sort the array after converting each element to its square.

Write a function ‘sortArrayAfterSquaring’ that takes an array of integers as input and returns the sorted array after converting each element to its square.

  • For example
    • Input: [1, 2, 3, 4, 5]
    • Output: [1, 4, 9, 16, 25]
    • Explanation:
      In this example, the input array is [1, 2, 3, 4, 5]. After squaring each element, we get [1, 4, 9, 16, 25]. The resulting array is then sorted in ascending order, which gives [1, 4, 9, 16, 25]. Finally, the sorted array is printed.

Input Format: Given an sorted array containing positive and negative numbers.

Output Format: Print the sorted array containing the squares of the numbers.

Question 4

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 5:

Problem Description

Question – : Juan Marquinho is a geologist and he needs to count rock samples in order to send it to a chemical laboratory. He has a problem: The laboratory only accepts rock samples by a range of its size in ppm (parts per million).

Juan Marquinho receives the rock samples one by one and he classifies the rock samples according to the range of the laboratory. This process is very hard because the number of rock samples may be in millions.

Juan Marquinho needs your help, your task is to develop a program to get the number of rocks in each of the ranges accepted by the laboratory.

Input Format: An positive integer S (the number of rock samples) separated by a blank space, and a positive integer R (the number of ranges of the laboratory); A list of the sizes of S samples (in ppm), as positive integers separated by space R lines where the ith line containing two positive integers, space separated, indicating the minimum size and maximum size respectively of the ith range.

Output Format: R lines where the ith line contains a single non-negative integer indicating the number of the samples which lie in the ith range.

Constraints:

  • 10 <= S <= 10000
  • 1 <= R <= 1000000
  • 1<=size of Sample <= 1000

Example 1

  • Input: 10 2
  • 345 604 321 433 704 470 808 718 517 811
  • 300 350
  • 400 700

Output: 2 4

Explanation:

There are 10 samples (S) and 2 ranges ( R ). The samples are 345, 604,811. The ranges are 300-350 and 400-700. There are 2 samples in the first range (345 and 321) and 4 samples in the second range (604, 433, 470, 517). Hence the two lines of the output are 2 and 4

Example 2

  • Input: 20 3
  • 921 107 270 631 926 543 589 520 595 93 873 424 759 537 458 614 725 842 575 195
  • 1 100
  • 50 600
  • 1 1000

Output: 1 12 20

Explanation:

There are 20 samples and 3 ranges. The samples are 921, 107 195. The ranges are 1-100, 50-600 and 1-1000. Note that the ranges are overlapping. The number of samples in each of the three ranges are 1, 12 and 20 respectively. Hence the three lines of the output are 1, 12 and 20.

FAQs related to Consultadd Coding Questions

Question 1: How many rounds are there in Consultadd Recruitment Process?

Consultadd has set different Hiring Process for Hiring Software Engineers and Management Trainee Engineers:

i.e. For Software Engineer:

  1. Coding Round: 1
  2. Personal Interview: 3 Technical Rounds

For Management Trainee Engineer:

  1. Group Discussion: 1
  2. Personal Interview: 2 Rounds
Question 2: Does Consultadd asks coding questions in Recruitment Process?

Yes, Coding Questions are included in Online Coding Test and Technical Interview of Consultadd.

Question 3: What is the eligibility criteria for the Job roles offered are at Consultadd India?

Consultadd has set different different Eligibility Criteria for Hiring freshers for Different Job Profiles like:

  1. For Software Engineer Level 1: B.Tech from CS/IT with Score of 65% throughout academics, Batch – 2024 are allowed.
  2. For Management Trainee Engineer: B.Tech from any Branch except CS/IT with Score of 65% throughout academics, Batch – 2024 are allowed.
Question 4: What is the salary offered by Consultadd India?

Salary offerd by Consultadd for:

  1. Software Engineer Level 1 = ₹ 8 – 12 LPA.
  2. Management Tainee Engineer = ₹ 5 LPA.

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