Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
This was a 1 hour online coding round on hackerrank platform. 3 DSA questions were given.
You may make as many transactions as you want but can not have more than one transaction at a time i.e, if you have the stock, you need to sell it first, and then only you can buy it again.
A max heap can be used here. In order to maximize the profit, the ticket must be for the seat in a row which has the maximum number of vacant seats and the number of vacant seats in that row will be decremented by 1 as one of the seats has just been sold. All the persons can be sold a seat ticket until there are vacant seats.
To find b’s complement: To find b’s complement, add 1 to the calculated (b-1)’s complement.
Steps to find (b-1)’s complement:
To find (b-1)’s complement, Subtract each digit of the number from the largest number in the number system with base b .
For example, if the number is a three-digit number in base 9, then subtract the number from 888 as 8 is the largest number in base 9 number system. The obtained result is the (b-1)’s (8’s complement) complement.
There are three numbers, say 8, 5 and 10.
8 can be written as 1 0 0 0 .
5 can be written as 0 1 0 1.
10 can be written as 1 0 1 0.
positions of the bits as i j k l.
So we can see majority bit at ith position are set bits so ith bit will be 1. Similarly for positions of j, k and l are set as 0 0 0 respectively.
So the number generated is 1 0 0 0 i.e. 8.
In this round, a DSA question was first asked. Then a lot of discussion regarding the various test cases around this question took place. (e.g, handing of -ve numbers , decimals , overflow etc).
Main concentration was just to get as many as test cases possible and an efficient solution as well.
And Some common question like why you coding in C++?
Scan each character of the input string and if a number is formed by consecutive characters of the string, we increment the result by that amount.
Time Complexity : O(n)
What are the advantages of OOPS?
OOP language allows to break the program into the bit-sized problems that can be solved easily (one object at a time).
The new technology promises greater programmer productivity, better quality of software and lesser maintenance cost.
OOP systems can be easily upgraded from small to large systems.
It is possible that multiple instances of objects co-exist without any interference,
It is very easy to partition the work in a project based on objects.
It is possible to map the objects in problem domain to those in the program.
The principle of data hiding helps the programmer to build secure programs which cannot be invaded by the code in other parts of the program.
By using inheritance, we can eliminate redundant code and extend the use of existing classes.
Again one coding question to be done on shared screen
In this example, this graph is directed and there are two triangles possible.
Triangle 1 : (0 3 2)
Triangle 2 : (0 1 2)
In this example, this graph is undirected and there are two triangles possible.
Triangle 1 : (0 3 2)
Triangle 2 : (0 1 2)
The naïve approach is to run three loops and keep track of the number of triangles possible so far. The three loops select three different values from array, the innermost loop checks for the triangle property ( the sum of any two sides must be greater than the value of third side).
Time Complexity: O(N^3) where N is the size of input array.
The efficient approach is based on the following fact :
Let a, b and c be three sides. The below condition must hold for a triangle (Sum of two sides is greater than the third side)
i) a + b > c
ii) b + c > a
iii) a + c > b
Following are steps to count triangle.
1. Sort the array in increasing order.
2. Initialize two pointers ‘i’ and ‘j’ to first and second elements respectively, and initialize count of triangles as 0.
3. Fix ‘i’ and ‘j’ and find the rightmost index ‘k’ (or largest ‘arr[k]’) such that ‘arr[i] + arr[j] > arr[k]’. The number of triangles that can be formed with ‘arr[i]’ and ‘arr[j]’ as two sides is ‘k – j’. Add ‘k – j’ to count of triangles.
4. Increment ‘j’ to fix the second element again.
5. If ‘j’ has reached end, then increment ‘i’. Initialize ‘j’ as ‘i + 1’, ‘k’ as ‘i+2’ and repeat the steps 3 and 4.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which SQL keyword removes duplicate records from a result set?