Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Coding Questions Asked in SAP Labs

11 / 18

Write a program to implement queue using linked list and array.

Input : NA

Output : NA

|  Queue | | | |  Fresher

Tags:SAP Labs

12 / 18

A password manager wants to create a new password using two strings given by the user, then combined to create a harder-to-guess combination. Given two strings, interleave the characters of the strings to create a new string. Beginning with an empty string, alternately append a character from string a and from string b. If one of the strings is exhausted before the other, append the remaining letters from the other string all at once. The result is the new password.

Example:
If a = saplab and b = q4interview ,the result is sqa4pilnatberview.

Function Description
Complete the function newPassword in the editor below
string a the first string
string b the second string

Input : a = saplab
b = q4interview

Output :

|  Strings | | | |  Fresher

Tags:SAP Labs

13 / 18

Build the Subsequences

A subsequence of a string is obtained by deleting zero or more characters from the string while maintaining order. Given a string, generate an array of all subsequences sorted alphabetically ascending, omitting the empty string.

Example
For example, the subsequences of string s = "xyz", not including the empty string, are "x", "xy", "xz", "xyz", "y", "yz", and "z"

Function Description:
Complete the function builds sequences in the editor below.

buildSubsequences has the following parameter(s)
str s: the string to process

Returns:
str[]: An array of strings comprising all the subsequences of the given string sorted alphabetically, ascending.

constraints:
1 < length of s <16
s is a string of distinct lowercase English alphabetic letter ascii[a-z]

Input : NA

Output : NA

|  Strings | | | |  Fresher

Tags:SAP Labs

14 / 18

Deleting Sub-strings

There are two strings, s, and t.

Perform two operationss with the string s:
1. Working from left-to-right delete each occurrence of t in s until there are no more occurrences of t. Count each deletion.
2. working from right-to-left delete each occurrence of t in s until there are no more occurrences of t. Count each deletion.

When that is done, return the greater of the two counts; deletion left-to-right or deletions right-to-left.

Example
s = 'bcbbc'
t = 'b'

From left to right:
Remove th first occurrence t = 'b' from"

Input : NA

Output : NA

|  Strings | | | |  Fresher

Tags:SAP Labs

15 / 18

Given a list of distinct unsorted integers, find the pair of elements that have the smallest absolute difference between them? If there are multiple pairs, find them all.
Input : arr[] = {10, 50, 12, 100}
Output : (10, 12)
The closest elements are 10 and 12

Input : arr[] = {5, 4, 3, 2}

Output :

|  Strings | | | |  Fresher

Tags:SAP Labs

16 / 18

Given an array of integers with repeating elements, find the sum of differences between positions of repeated elements and store them in an array of the same size.

For e.g. given array {1, 2, 3, 1, 2, 1, 2} we shall have:
For position 0: 1 is on positions 3&5 additional to position 0.
Thus for position 0: |3-0| + |5-0| = 8.
For position 1: 2 is on positions 4&6 additional to position 1.
Thus for position 1: |4-1| + |6-1| = 8.

Input : NA

Output : NA

|  Array | | | |  Experience, Fresher

17 / 18

Finding palindromic substrings within a string

For e.g. given string ‘banana’, palindromic substrings would be ‘aa’, ‘aaa’, ‘ana’, ‘anna’ and so on.

Input : NA

Output : NA

|  Array | | | |  Experience, Fresher

18 / 18

Find the count of prime numbers between l and r where 1 <= l, r <= 10 ^ 9 and those numbers whose digits are not even numbers and digits are less than 5

Eg :- l = 1
r = 10

Input : NA

Output : NA

|  Basics | | | |  Experience, Fresher

+ Contribute Programming Qs.

Baig
1