X

# Level - 2  Questions

View By:

Q1 Find the path in 2 Dimensional array which has the most 1

You have a m*n size 2 Dimensional Array filled with either 0 or 1. You have to figure out the path which contains the most 1 when starting from arr[0][0]. You can only traverse down or right.

For ex: If array has values

1 1 0 1 0 1 1 0 1 0 0 1

So here the path containing max 1 is arr[0][0], arr[0][1], arr[1][1], arr[1][2], arr[1][3] and arr[2][3]

Q2 Balanced BST

Find two elements in balanced BST which sums to a given a value. Constraints Time O(n) and space O(logn).
``````      6
3         8
``````

1 4 7 12

sum = 16 o/p should be 4 and 12

Q3 URL Detection

MS Word has the inbuilt logic to detect the url when user writes to any document. MS Word application detects the url typed by user and hyperlinks it. Write a code to:

1) Detect url assuming that MS Word engine streams the characters to your function BOOL DetectURL(UCHAR chUserCharEntry) 2) Once #1 is completed then execute the url from IE

Reorder A->B->C->D->E as B->A->D->C->E using linked list

Q5 Which fortune teller to choose

The first fortune teller's prediction has 85 % chance of being correct. The second has 63 % chance of being correct, the third 48 %, the fourth 32 %, and the fifth 9 %.

If you were trying to get the best prediction of your future, which fortune teller would you go to? • first • second • third • fourth • fifth

Q6 Find the number of times each character occurs in the string.

Calculate the frequency of each character in a given string

eg teddy d= 2 e=1 t=1 y=1

Q7 Find position of a string in another string

Find position of a string in another string.

Q8 Find position of a string in another string.

Find position of a string in another string. For example your first string is 'careerstack' and the second string is 'stack' then the output should be 7.

Q9 Find frequency of characters in a string.

How can you compute the frequency of characters in a string. For example in the string "code" each of the character 'c', 'o', 'd', and 'e' has occurred one time. Only lower case alphabets are considered.

Q10 Program to print all permutations of a given string.

A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself. A string of length n has n! permutation.

Below are the permutations of string ABC. ABC, ACB, BAC, BCA, CAB, CBA