## Recent Interview Questions

More Questions »- 0of 0 votes
Implement delete operation for N-ary tree. Your function should return a list of roots after deletion operation. Notice that your delete function only delete one node instead of a subtree. The delete function takes a list of nodes to be deleted.

`private class TreeNode { int val; TreeNode[ ] child; } List<TreeNode> delete(TreeNode root, HashSet<TreeNode> set) { }`

- 0of 0 votes
You have a grid of size N x M. Rows of the grid are numbered from 1 to N from top to bottom and columns of the grid are numbered from 1 to M from left to right. So, top-left corner is indexed as (1,1) and bottom-right corner is indexed as (N,M).

Cost of visiting a cell at index (i,j) is denoted by C[i][j]. Cost of changing the direction of your facing at index (i,j) is denoted by P[i][j].

You have to start from cell (1,1) and reach to cell (N,M) with minimum cost. At cell (1,1), you can either face towards 'Right' or face towards 'Down'. At any point of time, you can either face 'Right' or face 'Down'.

There are 2-types of moves allowed:

1. Move one cell towards the facing direction i.e. if you are facing 'Right', you can move one cell 'Right' or if you are facing 'Down', you can move one cell 'Down'. The cost of visiting cell (i,j) will be C[i][j].

2. Change the direction of facing i.e. if you are facing 'Right', you can now face 'Down' or if you are facing 'Down', you can now face 'Right'. The cost of changing the facing direction at cell (i,j) will be P[i][j].

Find the minimum cost to reach (N,M) after starting from (1,1).

Constraints:

1 <= T <= 3

1 <= N,M <= 1000

1 <= C[i][j], P[i][j] <= 1000

Input Format:

First line of each testfile contains T, the number of test cases.

In each testcase, First line contains two inetgers N and M denoting the dimensions of the grid.

Next N lines contains M integers each denoting the cost matrix C.

Next N lines contains M integers each denoting the cost matrix P.

- 0of 0 votes
given a stream of natural numbers ,

and a array J contains integers in increasing orders

operations performed J = [2,3,4]

1 2 3 4 5 6 7 8 9 10…………..27....100...1111

first operation

J[0] = 2 => remove every 2nd integer

now the stream is

1 3 5 7 … 27

J[1] = 3

remove every 3rd

stream is now

1 3 7 …

3rd

given a natural number n , find if it will survive given J, or at what index it will

die.

- 2of 2 votes
Return the length of longest possible chunked palindrome string.

Examples :

Input : VOLVO

Output : 3

Explanation :

(VO)L(VO)

Input : merchant

Output : 1

Explanation : No chunks possible.

Input :

ghiabcdefhelloadamhelloabcdefghi

Output : 7

Explanation :

(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)

- 0of 0 votes
Given a list of manager and employee information represented in hashMap entries {AAA->BBB,CCC,EEE},{CCC->DDD}.

Print company structure tree with proper indentations. BBB, CCC and EEE directly reports to AAA, so they have one white space before "-", DDD reports to CCC, it has two whitespace before "-". The input is map<String,List<String>>`-AAA -BBB -CCC -DDD -EEE`