Tip 1 : OOPs concepts are must.
Tip 2 : Choose any language and master it.
Tip 3 : Explain everything while coding in interview, and tell your approach.
Tip 1 : At least 2 projects.
Tip 2 : Highlight your achievements.
2 problems from leetcode were asked,
1. Best Time to Buy and Sell Stock
2. Remove K Digits
You can’t sell without buying first.
For the given array [ 2, 100, 150, 120],
The maximum profit can be achieved by buying the stock at minute 0 when its price is Rs. 2 and selling it at minute 2 when its price is Rs. 150.
So, the output will be 148.
Remember one rule :- You can only buy one time & sell one time
So, if buy at 7 & sell at any time in the future, we'll face loss. Because buying price is way higher then selling price available we have
Now, I have seen a dip & I buy at 1 & sell at 5 my overall profit will be 5 - 1 = 4
But what if, I had buy at 1 & sell at 6 my profit will be 6 - 1 = 5. Which is greater then my overall profit. So, i will update my overall profit with new value.
‘num’ does not have leading zeros except when ‘num’ equals zero.
Input: ‘num’ = ‘141’ , ‘k’ = 1.
Output: ‘11’
Explanation: By removing only 1 digit from ‘num’, 3 numbers can be formed: 14, 11, and 41. Out of which 11 is the smallest number.
You don’t have to print anything. It has already been taken care of. Just implement the given function.
1. Deleting k digits means keeping n - k digits, where n is the total number of digits.
2. Use a stack that you keep sorted ascendingly. You remove elements from it as long as you can still make it to n - k digits,
and your current element is smaller than the top of the stack:
push(2) => 2
push(4) because 2 < 4 => 24
push(6) because 4 < 6 => 246
pop() because 3 < 6 and we can still end up with 2 digits => 24
pop() for the same reason => 2
push(3) => 23
push(5) => 235
Then just take the first k digits => 23. Or you can make sure never to push more than k digits, and then the final stack is your solution.
3. Note that you cannot pop elements if that means you will not be able to build a solution of k digits.
For this, you need to check the current number of elements in the stack and the number of digits to the right of your current position on the input number.
Online Coding round.
1. The matrix may also contain some negative elements.
2. A square matrix is a matrix with the same number of rows and columns.
A matrix obtained by deleting some (possibly zero) of the rows and/or columns from the beginning and/or from the end of a matrix is said to be a sub-matrix of the given matrix.
Example: Given a matrix
A = 1 2
3 4
Possible non-empty sub-matrices of A are represented below by bold numbers-
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which keyword is used for inheritance?