## Intern Interview Questions

- 0of 0 votes
Convert Roman to integer and vice-versa

- 0of 0 votes
Print a binary tree level by level and zig zag order.

- 1of 1 vote
Write a program to return nearest elements from a binary search tree for input element.

- 0of 0 votes
There is a dictionary already implemented. Write a method , which takes input String without space, to replace the characters from the strings which are not present in dictionary with –

Example: Dictionary – a*

………….Input- aaabaa

………….Output- aaa_aa

- 0of 0 votes
There is a dictionary already implemented. Write a method, which takes input String without space, to prints all subsets of the input string which is present in dictionary.

Example: Dictionary – a*

………….Input- aaabaa

………….Output- a,a,a,aa,aa,aaa,a,a,aa

- 0of 0 votes
We were given an array. Values of the array were memory sizes and the memory that is required by the system can only be represented in powers of We had to return the size of the memory required by the system.

Ex: – arr = {2,1,4,5}

Total = 12

So, memory required =16

- 0of 0 votes
Given an array arr[], find the maximum j – i such that arr[ j ] > arr[ i ]

- 0of 0 votes
Given two arrays find the min in first array and max in the second array and return the product of the two elements

- 0of 0 votes
given a target node in a directed graph, find the shortest cycle including this node, return the whole path.

- 0of 0 votes
Given that :

A -> 1

B -> 2

…

Z -> 26

AA -> 27

AB -> 28

…

BA -> 53

Write a function that returns the value given a string of uppercase letters.

- 1of 1 vote
Given an array of objects with a known set of properties , implement a function that finds all possible partial matches (one object's property value matches the same property on another object), and produce a results object that describes those matches in any format you want.

- 0of 0 votes
You are in charge of a classroom which has n seats in a single row, numbered 0 through n-1.

During the day students enter and leave the classroom for the exam.

In order to minimize the cheating, your task is to efficiently seat all incoming students.

You're given 2 types of queries: add_student(student_id) -> seat index, and remove_student(student_id) -> void.

The rules for seating the student is the following:

1) The seat must be unoccupied

2) The closest student must be as far away as possible

3) Ties can be resolved by choosing the lowest-numbered seat.

- 3of 3 votes
Given two sorted arrays A and B. Find the first K pairs (a, b) from A and B which have the smallest sum of a & b. Supposed K is small compared to |A| x |B|

For example:

A = [1, 2, 3, 6, 10]

B = [1, 4, 5, 7]

K = 5

Result [(1,1), (1,4), (1,5), (2,1), (3,1)]

- 1of 1 vote
Given a sorted distinct array of integers and a key K. C closest elements to K are in range [L,R] inclusive, L<=R. Return L as the left index of C closest elements to K.

For example:

A = [1, 2, 5, 8, 9, 13]. K = 8 and C = 4. The result L = 3 because 4 closest elements to 8 are [5, 8, 9, 13]

- 0of 0 votes
You are given an island which contains cliffs of various heights. A water droplet is placed on one of the cliffs. The water droplet always flows from higher height to lower height. Write a program that can calculate the lowest height cliff in the island that the water droplet can reach in the most efficient way you can think of. Example: if the droplet is placed on a cliff of height 5 and it is surrounded by cliffs of heights 6,3,2,2; it can flow to either of the cliffs of height 3,2,2 and then further flow from there.

- 0of 0 votes
Given String is "a4b2c2a3f1g2" and out put should be "aaaabbccaaafgg" . the number after char is the occurance of that character in string.

- 0of 0 votes
Given a robot which is on Origin in a number line and a string that contains either ‘L’ , ‘R’ or ‘?’. ‘L’ means turn left and ‘R’ means turn right. ‘?’ can be assumed to be ‘L’ or ‘R’. Find the maximum distance from origin the robot can go at any point of time.

- 0of 0 votes
Given a robot which is on Origin in a number line and a string that contains either ‘L’ , ‘R’ or ‘?’. ‘L’ means turn left and ‘R’ means turn right. ‘?’ can be assumed to be ‘L’ or ‘R’. Find the maximum distance from origin the robot can go at any point of time.

- 0of 0 votes
Considering a server that should ignore requests older than 1 second, create a structure to handle this behavior and give its complexity.

Use any language you want.

- 0of 0 votes
Implement, recursively, fast exponentiation and give its complexity.

Use any language you want.

- 0of 0 votes
Design the movement algorithm of a snake from snake game and give its complexity. You can base your idea of algorithm in whatever design for the game. eg. a matrix to represent the grid, use a linked list to represent the snake...

Use any language you want.

- 0of 0 votes
Create a structure to store the median of people ages and give its complexity. If keeping ordered ages, also give the insertion complexity.

Use any language you want.

- 1of 1 vote
Calculate and replace repeated characters in a string with their number of occurrences.

Example :

aaaggbbbbc

3a2g4b1c

- 1of 1 vote
Sort elements by frequency, print the elements of an array in the decreasing frequency if 2 numbers have same frequency then print the one which came first.

- 2of 2 votes
Design a stock market system

- 0of 0 votes
Given 2 sorted linked lists, return a linked list that has all the elements and is sorted.

- 0of 0 votes
Given 3 strings "s" ssearch" and "sreplace", search string s for the substring ssearch and for every instance of ssearch you find, replace that part of the string with sreplace

- 0of 0 votes
Given an NxN Boolean matrix, find how many true regions there are in the matrixj

- 0of 0 votes
Create a basic minesweeper game that allows for board creation with custom height, width and number of mines. Create a <click> function that will take in a board location and return whether the user has won, lost, or the number of surrounding mines.

- 0of 0 votes
Given a string, print out all of the unique characters and the number of times it appeared in the string