Tip 1 : Practice Atleast 250 Questions
Tip 2 : Make atleast 2 projects
Tip 1 : Have some projects on resume
Tip 2 : Do not put false things on resume
Aptitude questions + 2 medium level Coding Problem
knightPosition: {3,4}
targetPosition: {2,1}
The knight can move from position (3,4) to positions (1,3), (2,2) and (4,2). Position (4,2) is selected and the ‘stepCount’ becomes 1. From position (4,2), the knight can directly jump to the position (2,1) which is the target point and ‘stepCount’ becomes 2 which is the final answer.
1. The coordinates are 1 indexed. So, the bottom left square is (1,1) and the top right square is (N, N).
2. The knight can make 8 possible moves as given in figure 1.
3. A Knight moves 2 squares in one direction and 1 square in the perpendicular direction (or vice-versa).
This question is a type of 0-1 knapsack problem.
In the Dynamic programming we will work considering the same cases as mentioned in the recursive approach. In a DP[][] table let’s consider all the possible weights from ‘1’ to ‘W’ as the columns and weights that can be kept as the rows.
The state DP[i][j] will denote maximum value of ‘j-weight’ considering all values from ‘1 to ith’. So if we consider ‘wi’ (weight in ‘ith’ row) we can fill it in all columns which have ‘weight values > wi’. Now two possibilities can take place:
Fill ‘wi’ in the given column.
Do not fill ‘wi’ in the given column.
Now we have to take a maximum of these two possibilities, formally if we do not fill ‘ith’ weight in ‘jth’ column then DP[i][j] state will be same as DP[i-1][j] but if we fill the weight, DP[i][j] will be equal to the value of ‘wi’+ value of the column weighing ‘j-wi’ in the previous row. So we take the maximum of these two possibilities to fill the current state
Interview was in the afternoon
Tell me about yourself
What do you know about the company
Where do you see yourself in 5 years
Are there any questions you want to ask me
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you select an element by class name in CSS?