## Intern Interview Questions

- 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

- 0of 0 votes
Given a singly linked list of integers, write a function in java that returns true if the given list is palindrome, else returns false

- -3of 3 votes
Convert an unordered tree to a binary tree

- 1of 1 vote
merge two binary search trees

- 0of 0 votes
Sort a stack using only one other stack and no recursion.

- 3of 3 votes
Write an algorithm that returns any duplicate in an array of integers. The algorithm must run in O(n) time and O(1) space. (hint: the integers in the array are not greater than the size of the array).

- 0of 0 votes
Add a node to sorted circular linked list

- 0of 0 votes
You have a string aaabbdcccccf, transform it the following way => a3b2d1c5f1

ie: aabbaa -> a2b2a2 not a4b2

- 0of 0 votes
There is a DNA Strand having values as A , T , C , G.

All combinations are present in the the file.

Write a method which takes starting mutation string , ending mutation string and string bank and calculates the minimum mutation distance required. But the condition is that either of the start or end must be present in the bank.

Input:

AATTGGCC is starting and TTTTGGCA is ending then mutation distance will be 3.

AATTGGCC - TATTGGCC - TTTTGGCC - TTTTGGCA as it takes three mustaion for start to reach the end string and for this , all intermediate string and final string must be present in the bank.

static int findMutationDistance(String start, String end, String[] bank) {

}

- 0of 0 votes
You have a string of phrases present. For your simplicity consider them to be integer length.

String s= " I am Tom"

will be stored in an interger array as [1,2,3] where each represents length of each word in the string.

Write a method to compute the longest subsequence such that it is less than given k value.

Input:

3 //length of array

1 //a[0]

2 //a[1]

3 //a[2]

4 // value of k

Output:

2

Input:

4 //length of array

3

1

2

1

4 //value of k

Output:

3

static int maximumLength(int[] a, int k) {

}

- 0of 0 votes
CAREERCUP is a boad game hat contains m x n on a board. The objective of the CAREERCUP game is to reach the bottom of he board (bottom right corner) from the top of the board (top left corner) while moving one grid at a ime in either the down, right or diagonally downwrd directions.

Write a method called CareerSolution that takes in two integers representing m and n, and returns the total number of ways a player can complete the game.

PS: Was later asked to optimize the solution.

int CareerSolution(int m, int n) {

}