Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
Practice Tech Mahindra Essay Topics

# HackerRank Test Coding Questions Answers

1 / 29

Given an array of size MxN and coordinates of starting of subarray (x, y). You need to rotate that subarray and then print the full array after rotation.

Input : NA

Output : NA

|  Array | | | |  Fresher

Tags:Nagarro

2 / 29

Given a string, say sentence=" this is crazy and fun" and a list, say name=["is", "fun"]. Now you need to capitalize on the first letter of every word in the given string which is not present in the list.

Input : this is crazy and fun

Output :

|  Strings | | | |  Fresher

Tags:Nagarro

3 / 29

Given three sorted arrays A, B, and C. Write the most efficient algorithm to find the 5th largest element among the three arrays.

Input : NA

Output : NA

|  Array | | | |  Fresher

Tags:Nagarro

4 / 29

Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number.

Input : n =10

Output :

|  Basics | | | |  Fresher

5 / 29

For given a positive integer N, return the sum of digits at even places and odd places. Write a program for it.

Input : NA

Output : NA

|  Basics | | | |  Fresher

6 / 29

For given a string and an integer N, reverse N letters from the string. Write a program for it.

Input : NA

Output : NA

|  Strings | | | |  Fresher

7 / 29

Find the 4th nearest prime number for a given number n. Write a program for it.

Input : NA

Output : NA

|  Basics | | | |  Fresher

8 / 29

Sort a list of dates in ascending order given the data format shown below:

Each date is in the form ddmmmyyyy where
dd is the set {0-31}
mmm is in the set {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)
yyyy is four digits.

Example
dates = {'01 Mar 2017';'03 Feb 2017';'15 Jan 1998']
The array dates sort to ['15 Jan 1998';'03 Feb 2017';'01 Mar 2017';]

Input : {'01 Mar 2017';'03 Feb 2017';'15 Jan 1998']

Output :

|  Strings | | | |  Fresher

Tags:SAP Labs

9 / 29

Given two vectors. One contains array element "ele" and other indexes "ind" to push the corresponding element at that index in new array shifting all elements to its right.

Example:
Intput:
ele = {0, 1, 2, 3, 4} ind ={0, 1, 2, 1, 2}

Output: {0, 3, 4, 1, 2}

Input : ele: {0, 1, 2} ind: {0, 1, 0}

Output :

|  Array | | | |  Fresher

Tags:SAP Labs

10 / 29

Write a program to generate a simple pattern.
1
12
123
1234
123
12
1

Input : 4

Output :

|  Basics | | | |  Fresher

Tags:SAP Labs

+ Contribute Programming Qs.

Baig
1