Kotak SDE Coding Questions and Answers

Kotak Coding Question and Answer

Kotak Mahindra Bank SDE Coding Question and Answer :

In this page we have given the latest coding question and their answers asked in Kotak Mahindra Bank  for SDE 1 role.

Kotak Mahindra Bank SDE 1 Coding Questions and Answers

RoundsPattern  Time
 Round 1DSA Round test 60 mins
Round 2DSA + Project Round + CS Fundamental test 45-60mins
 Round 3DSA with Oops test 45-60 mins
 Round 4Hiring Manager Round 1 – 1.5 hrs

                                              Question 1: Stars Between Bars

Given a string s consisting of stars “*” and bars  “|” ,an array of starting indices starIndex, and an array of ending indices endIndex, determine the number of stars between any two bars within the substrings between the two indices inclusive . NOTE that in this problem indexing starts at 0.

  • A Star is represented as an asterisk [*=ascii decimal 42]
  • A Bar is represented as a Pipe [“|”=ascii decimal 124]

Example

s=’|**|*|’
n = 2
startIndex=[0,0]
endIndex=[4,5]

  • For the first pair of indices (0,4) the substrings is “|**|*”  . There are 2 stars between a pair of bars
  • For the second pair of indices (0,5) the substring is  “|**|*|” and there are 2+1=3 stars in between the bars.
  • Both of the answers are returned to the array [2,3].

Constraints

  • 1 <= n <= 105
  • 1 <= StartIndex[i] <= endIndex[i]
  • Each Character of s is either “*” or “|”

Input Format for Custom testing

First line contains a string S. The next line contains an integer n , the no.of elements in startIndex and endIndex. Each line i of the n subsequent lines contains an integer of startIndex. Each line i of the n subsequent lines contains an integer of endindex.

Sample Input

*|*|  → s=”*|*|”
1 → size of startindex[] and endIndex[] is 1.
0 → startindex = 0
2 → endindex = 2

Sample output:

0

Explanation :

The substring from index = 0 to index = 2 is “*|*” . there is no consecutive pair of bars in this string.

Prime Course Trailer

Related Banners

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

                                                                                     Question 2 : Duplicates

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.

Input Format:

  • First line takes n, which is the total no. of mails recieved.
  • Second line takes the n no. of email id as input./li>

Output Format:

Total no. of duplicate email id’s to be deleted.

Constraints:

  • 1 <= n <= 10^4

Sample input:

  • 6   
  • 1 3 3 4 3 3

Sample output

  • 3

Question 3 : Last student’s ID

Problem Statement  :

There is an id code that is supposed to be given to all the aspirants of an exam. It is actually a substring of a given string. That means, the authority takes a string and then assigns all the unique substrings to all the students. Suppose there is a string “abcde”, so the ids of the students will be “a”,”b”,”c”,”d”,”e”,’ab”,”abc”,”abcd”,”abcde”,”bc”,”bcd”,”bcde”,”cd”,”cde”,”de”.

The students are standing in a line according to the lexicographic order of their given ids. You have to find out the id of the last student for the given input string from which the ids are generated.

Input Format:
Single line with the id generating string
Output format:
The last id as per lexicographical order

Constraints:
Number of characters in the string<=10^9

Sample Input:
abdc

Sample output:
dc

Explanation:
The last student will be with the id dc. The order will be
abdc
a
ab
abd
abdc
b
bd
bdc
c
d
dc

Question 4 :Make It Palindrome

Problem Statement  :

You’re given a string, you’ve to print additional characters needed to make that string a palindrome.

A Palindrome is a sequence of characters that has the property of reading the same in either direction.

Input :
abede
Output :
ba

Sample Input :
abcfe

Sample output :
fcba

Question 5: Class Monitor

Problem Statement :

After JEE Mains, some students got admission into an engineering college. Now there is a class consisting of such n students, and the HOD came to say it is time to select the class monitor. But He never gets all of them at one time. So he brought a register, every time he gets someone with less rank than the previous time he cut the name and wrote the name of the student and the rank.
For a given number of ranks he gets each time, you have to predict how many names are cut in the list.

Constraints:
Number of Visiting<=10^9
ranks <=10000

Input Format:
Number of Visiting N in their first line
N space separated ranks the HOD gets each time

Output Format:
Number of ranks cut in the list

Sample Input:
6
4 3 7 2 6 1

Sample Output:
3

Question 6 : Help of Prepsters

Problem Statement :

Arnab has given me a challenge. I have to calculate the number of numbers which are less than a certain value n, and have exactly k set bits in its binary form. As you are a Prepster like me, help me write a code that will take input for n and k and give the expected output.

Constraints :
1<=n<=10000
1<=k<=10
Input Format :
First line containing n and k space separated
Output Format :
Number of numbers present in a single line

Sample Input:
7 2
Sample Output:
3
Explanation:
11,110,101 -> These three numbers.

Question 7: HR issues

Problem statement :

Shovon is an HR in a renowned company and he is assigning people to work. Now he is assigning people work in a fashion where if he assigns some work a work of cost 2, the next person will be strictly getting a job with cost equal or more than 2. Given that Shovon’s company has infinite work and a number of employees, how many distributions can be possible. The cost of jobs can go 0 to 9.

Function Description:

Complete the special_numbers function in the editor below. It has the following parameter(s):

Parameters:

NameTypeDescription
NIntegerThe number of depts.
arr[ ]Integer arrayThe number of  employees in each dept..

Return: The function must return an INTEGER denoting the sum of answers for all distinct distributions.

Constraints:

  • 1 <= n <= 100
  • 1 <= arr[i] <= 200

Sample Cases:

  • Sample Input 1
    2
    4
    1
  • Sample Output 1
    725
  • Description
    The ans if m = 1 is 10, which is all numbers from 0 to 9
    The ans for m = 2 is 55
    The answer for m = 3 is 220
    The answer for m = 4 is 715
    So fun(4) + fun(1) = 725

Question 8 : Maneuvering a Cave Problem

Problem Description

The task is to count all the possible paths from top left to bottom right of a m x n matrix with the constraints that from each cell you can either move only to right or down.

Input: 

  • First line consists of T test cases. First line of every test case consists of N and M, denoting the number of rows and number of columns respectively.

Output: 

  • Single line output i.e count of all the possible paths from top left to bottom right of a m x n matrix..

Constraints:

  • 1<=T<=100
  • 1<=N<=100
  • 1<=M<=100

Question 9 :

How will we represent a binary tree? We can use a bracket structure for all of the edges, like (Parentnode , Childnode). Now if we use a node in child node more than once, the tree can not be valid. Same for the parent node, a node can not be taken more than twice in  a graph as a parent node.

Suppose we see this one graph

(P,Q)(P,R)(Q,T)(R,W)(U,V)(Q,S)(R,U)(U,Z)(S,I)(W,Y)

A tree with those edges may be illustrated in many ways.Here are two:

                   P                            P

                /    \                        /     \

              Q      R                   Q      R

            /   \     /    \               /   \    /  \

          S   T   U   W           S    T  U  W

            \        / \     \          /          / \      \

             I     V  Z    Y      I         Z  V    Y

The following is a recursive definition for the S-expression of a tree.

S-exp(node)=(node->val(S-exp(node->first_child))(S-exp(node->second_child))),if node

!NULL=””,node= =NULL

         Where first_child->valval(first_child->val is lexicographically than second_child->val)

This tree can be represented in S-expression in multiple ways.The lexicographically smallest way of expressing it as follows:

P(Q(S(I))(T))(R(U(V)(Z))(W(Y))))

Translate the node-pair representation into its lexicographically smallest S-expression or report any errors that do not conform to the definition of the binary tree.

The List of errors with their codes is as follows: 

Error                               Reason

Code Stopped1                More than 2 children

Code Stopped2                Duplicate Edges

Code Stopped3                Cycle Present(node is direct descendant of more than one node)

Code Stopped4                Multiple Roots

Code Stopped5                Any other error

Constraints:

  1. All node names are single characters in the range ascii[A-Z].
  2. The maximum node count is 26.
  3. There is no specific order to the input (parent,child) pairs.

>Input Format for Custom Testing

>Sample Case 0

Sample Input 0

  • (B,D) (D,E) (A,B) (C,F) (E,G) (A,C)

Sample output 0

  • (A(B(D(E(G))))(C(F)))

Explanation 0

A representation of tree is as follows:

             A

           /    \

         B      C

         /         \

       D           F

      /

     E

    /

  G

>Sample Case 1

Input:

  • (C,E)(D,F)(A,B)(A,C)(B,K)

Output:

  • A(B(K))(C(E)))D(F))

Question 10: Consecutive Prime Sum

Problem Description

Question – :  Some prime numbers can be expressed as a sum of other consecutive prime numbers.

  • For example
    • 5 = 2 + 3,
    • 17 = 2 + 3 + 5 + 7,
    • 41 = 2 + 3 + 5 + 7 + 11 + 13.
      Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2.

Write code to find out the number of prime numbers that satisfy the above-mentioned property in a given range.

Input Format: First line contains a number N

Output Format: Print the total number of all such prime numbers which are less than or equal to N.

Constraints: 2<N<=12,000,000,000

FAQs related to Kotak Mahindra SDE

Question 1: What is the role offered in Kotak Mahindra Bank?

The roles offered in this hiring of  Kotak Mahindra Bank is for Software Development Engineer , your role would initially involve extensive training for imparting the required level of skills, for effectively carrying out the official responsibilities assigned to you.

Question 2: What is Kotak Mahindra Bank Recruitment Process?

The Online Selection Process consist of 

  • 3 Written test of DSA
  • Technical + Hiring Manager Round  interviews
Question 3:What is online assessment test in Kotak Mahindra Bank?

The Online Assessment consist of

  • DSA Coding Question
  • Computer Fundamental Questions
  • Question Based on Projects
Question 4: What should be need to prepare for successfully cleared the test?

 For successfully clearing the tests, you should prepare DSA completely with proper practice along with that you should also prepare computer fundamental questions.

Question 5: What is the Salary offered for the roles?

The Salary Package for Kotak Mahindra Bank Software Development engineer is in between 10 – 12 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