Tip 1 : You have to give time to coding at least 1 hr per day.
Tip 2 : First, clear your basics, then go for advanced topics.
Tip 1 : Make good projects and put unique things on your resume.
Tip 2 : Also always updated your resume with your live coding contest ranking
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).
Take the target array first.
Initialize the result as 0.
If all are even, divide all elements by 2
and increment the result by 1.
Find all odd elements, and make them even by
reducing them by 1. and for every reduction,
increment result by 1.
Finally, we get all zeros in the target array.
The idea is based on school mathematics. We traverse both strings from end, one by one add digits and keep track of carry. To simplify the process, we do following:
1) Reverse both strings.
2) Keep adding digits one by one from 0’th index (in reversed strings) to end of smaller string, append the sum % 10 to end of result and keep track of carry as sum/10.
3) Finally reverse the result.
1 ‘X’: Enqueue element ‘X’ into the end of the nth queue. Returns true after the element is enqueued.
2: Dequeue the element at the front of the nth queue. Returns -1 if the queue is empty, otherwise, returns the dequeued element.
Enqueue means adding an element to the end of the queue, while Dequeue means removing the element from the front of the queue.
enQueue(q, x):
While stack1 is not empty, push everything from stack1 to stack2.
Push x to stack1 (assuming size of stacks is unlimited).
Push everything back to stack1.
Here time complexity will be O(n)
deQueue(q):
If stack1 is empty then error
Pop an item from stack1 and return it
Here time complexity will be O(1)
‘ARR1’ = [3 6 9 0 0]
‘ARR2’ = [4 10]
After merging the ‘ARR1’ and ‘ARR2’ in ‘ARR1’.
‘ARR1’ = [3 4 6 9 10]
The idea is to use Merge function of Merge sort.
Create an array arr3[] of size n1 + n2.
Simultaneously traverse arr1[] and arr2[].
Pick smaller of current elements in arr1[] and arr2[], copy this smaller element to next position in arr3[] and move ahead in arr3[] and the array whose element is picked.
If there are remaining elements in arr1[] or arr2[], copy them also in arr3[].
F(n) = F(n-1) + F(n-2),
Where, F(1) = F(2) = 1.
For ‘N’ = 5, the output will be 5.
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation
Fn = Fn-1 + Fn-2
with seed values F1 = 1 and F2 = 1.
The first number is 1.
This is read as “One 1”.
Hence, the second number will be 11.
The second number is read as “Two 1s”.
Hence, the third number will be 21.
The third number is read as “One 2, One 1”.
Hence, the fourth number will be 1211. And so on.
The fourth term is read as “One 1, One 2, Two 1s”.
Hence, the fifth term will be 111221. And so on.
The idea is simple, we generate all terms from 1 to n. First, two terms are initialized as “1” and “11”, and all other terms are generated using previous terms. To generate a term using the previous term, we scan the previous term. While scanning a term, we simply keep track of the count of all consecutive characters. For a sequence of the same characters, we append the count followed by the character to generate the next term.
Introduction
Project
Talking about my hometown like what is a famous thing and what is a unique thing in that?
Why should we hire you?
Long-term and short-term goals
Where do you see yourself in 5 years?
Strengths and weakness
Tip 1 : Always be pure
Tip 2 : Don't lie
Tip 3 : Be confident
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which operator is used for exponentiation in Python?