Practice DP based questions as much as you can. Also, be confident during the interview about your solution. For practice, you can prefer Coding Ninjas and Geeks For Geeks.
Keep it short. Mention the academic and professional projects you've done. Add your educational details properly with percentage or CGPA obtained.
The interviewer called my via phone and simultaneously provided me a link where I had to write the code for a given problem. It was scheduled at 12:30 pm, so timing was not an issue. It was a standard DP question involving a 2D matrix. The question was easy and I was able to code it within given time.
Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m, n) from (0, 0). Each cell of the matrix represents a cost to traverse through that cell. Total cost of a path to reach (m, n) is sum of all the costs on that path (including both source and destination). You can only traverse down, right and diagonally lower cells from a given cell, i.e., from a given cell (i, j), cells (i+1, j), (i, j+1) and (i+1, j+1) can be traversed. You may assume that all costs are positive integers.
For example, what is the minimum cost path to (2, 2)?
The path with minimum cost is highlighted in the following figure. The path is (0, 0) –> (0, 1) –> (1, 2) –> (2, 2). The cost of the path is 8 (1 + 2 + 2 + 3).
The interviewer asked me two coding questions in this round.
Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.
Given a decimal number as N, the task is to convert N into an equivalent irreducible fraction.
An irreducible fraction is a fraction in which numerator and denominator are co-primes i.e., they have no other common divisor other than 1.
Examples:
Input: N = 4.50
Output: 9/2
Explanation:
9/2 in decimal is written as 4.5
Input: N = 0.75
Output: 3/4
Explanation:
3/4 in decimal is written as 0.75
This was on-site round at their Bangalore office. The interviewer was friendly and helpful. The interview held inside a conference room.
Given an integer N as input, the task is to print the Magical Pattern as given below:
N . . 3 2 1 2 3 . . N
. . . . . . . . . . .
3 3 3 3 2 1 2 3 3 3 3
2 2 2 2 2 1 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 1 2 2 2 2 2
3 3 3 3 2 1 2 3 3 3 3
. . . . . . . . . . .
N . . 3 2 1 2 3 . . N
Examples:
Input: 3
Output:
3 2 1 2 3
2 2 1 2 2
1 1 1 1 1
2 2 1 2 2
3 2 1 2 3
Input: 4
Output:
4 3 2 1 2 3 4
3 3 2 1 2 3 3
2 2 2 1 2 2 2
1 1 1 1 1 1 1
2 2 2 1 2 2 2
3 3 2 1 2 3 3
4 3 2 1 2 3 4
V is the number of vertices present in graph G and vertices are numbered from 0 to V-1.
E is the number of edges present in graph G.
The Graph may not be connected i.e there may exist multiple components in a graph.
This was the next round of the onsite interviews. Took place in the same conference room as that of the previous round.
Given a node, how long will it take to burn a whole binary tree?
Given an array A[] consisting of N integers, the task is to find the total number of subsequence which contain only one distinct number repeated throughout the subsequence.
Examples:
Input: A[] = {1, 2, 1, 5, 2}
Output: 7
Explanation:
Subsequences {1}, {2}, {1}, {5}, {2}, {1, 1} and {2, 2} satisfy the required conditions.
Input: A[] = {5, 4, 4, 5, 10, 4}
Output: 11
Explanation:
Subsequences {5}, {4}, {4}, {5}, {10}, {4}, {5, 5}, {4, 4}, {4, 4}, {4, 4} and {4, 4, 4} satisfy the required conditions.
This was the third round of the onsite interview.
Given two strings str1 and str2 and below operations that can performed on str1. Find minimum number of edits (operations) required to convert ‘str1’ into ‘str2’.
Insert
Remove
Replace
All of the above operations are of equal cost.
Input: str1 = "geek", str2 = "gesek"
Output: 1
We can convert str1 into str2 by inserting a 's'.
Input: str1 = "cat", str2 = "cut"
Output: 1
We can convert str1 into str2 by replacing 'a' with 'u'.
Input: str1 = "sunday", str2 = "saturday"
Output: 3
Last three and first characters are same. We basically
need to convert "un" to "atur". This can be done using
below three operations.
Replace 'n' with 'r', insert t, insert a.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is the index number of the last element of an array with 9 elements?
This Comment was removed by the moderator
This comment won't show up to you, as it was removed by moderator due to inappropriate content.