Tip 1: Basics of DSA should be clear, think out loud
Tip 2: Dry the code
Tip 3: Cover all test cases
Tip 1 : Mention at least 2 project
Tip 2 : Do add too many extracurricular activities
Tip 3 : having internship experience is a plus



The start time of one chosen meeting can’t be equal to the end time of the other chosen meeting.
'N' = 3, Start = [1, 3, 6], End = [4, 8, 7].
You can organize a maximum of 2 meetings. Meeting number 1 from 1 to 4, Meeting number 3 from 6 to 7.
The idea is to solve the problem using the greedy approach which is the same as Activity Selection Problem i.e. sort the meetings by their finish time and then start selecting meetings, starting with the one with least end time and then select other meetings such that the start time of the current meeting is greater than the end time of last meeting selected



If “nums” = {2, 1, 3}.
The valid non-empty subsequences of the array are {2}, {1}, {3}, {2, 1}, {1, 3}, {2, 3} and {2, 1, 3}. So, the longest subsequence satisfying the given conditions are {2, 1} and {2, 3}. The length of the longest subsequence is 2. So, the answer is 2.
Any subsequence of length = 1 is also a valid subsequence.
The idea is that all the non-negative numbers must be included in the sub-sequence because such numbers will only increase the value of the total sum.
Now, it’s not hard to see among negative numbers, the larger ones must be chosen first. So, keep adding the negative numbers in non-increasing order of their values as long as they don’t decrease the value of the total sum below 0



Consider a country having 4 states numbered from 1 to 4. These 4 states are connected by 5 bidirectional roads given as :
1 --- 2 with cost = 8
2 --- 3 with cost = 6
3 --- 4 with cost = 5
1 --- 4 with cost = 2
1 --- 3 with cost = 4
The map of the country can be represented as:

Now, the best way to choose 3 roads is:

The cost of travelling from any state to all other states is 2 + 4 + 6 i.e. 12.
The approach is very simple, just travel by the bus which has the lowest cost so far. Whenever a bus with an even lower cost is found, change the bus from that city. Following are the steps to solve:
Start with the first city with a cost of C[1].
Travel to the next city until a city j having cost less than the previous city (by which we are travelling, let’s say city i) is found.
Calculate cost as abs(j – i) * C[i] and add it to the total cost so far.
Repeat the previous steps until all the cities have been traversed.



Let S = “ababc”. The lexicographically smallest subsequence containing all the distinct characters of strings is “abc”.
Strings consist of only lowercase characters.
You do not need to print anything; it has already been taken care of. Just implement the function.
First of all, by induction it can prove that the product of count of ‘x’ and count of ‘y’ should be equal to the sum of the count of a subsequence of ‘xy’ and ‘yx’ for any given string. If this does not hold then the answer is ‘Impossible’ else answer always exist.
Now, sort the given string so the count of a subsequence of ‘yx’ becomes zero. Let nx be the count of ‘x’ and ny be count of ‘y’. let a and b be the count of subsequence ‘xy’ and ‘yx’ respectively, then a = nx*ny and b = 0. Then, from beginning of the string find the ‘x’ which has next ‘y’ to it and swap both until you reach end of the string. In each swap a is decremented by 1 and b is incremented by 1. Repeat this until the count of a subsequence of ‘yx’ is achieved i.e. a becomes p and b becomes q.



Traverse the list individually and keep putting the node addresses in a Hash Table.
At any point, if NULL is reached then return false
If the next of the current nodes points to any of the previously stored nodes in Hash then return true.

The given linked list is -

If K = 3, then the list after rotating it by K nodes is:

1. The value of any node in the linked list will not be equal to -1.



For a (6 x 6) board, the numbers are written as follows:

You start from square 1 of the board (which is always in the last row and first column). On each square say 'X', you can throw a dice which can have six outcomes and you have total control over the outcome of dice throw and you want to find out the minimum number of throws required to reach the last cell.
Some of the squares contain Snakes and Ladders, and these are possibilities of a throw at square 'X':
You choose a destination square 'S' with number 'X+1', 'X+2', 'X+3', 'X+4', 'X+5', or 'X+6', provided this number is <= N*N.
If 'S' has a snake or ladder, you move to the destination of that snake or ladder. Otherwise, you move to S.
A board square on row 'i' and column 'j' has a "Snake or Ladder" if board[i][j] != -1. The destination of that snake or ladder is board[i][j].
You can only take a snake or ladder at most once per move: if the destination to a snake or ladder is the start of another snake or ladder, you do not continue moving - you have to ignore the snake or ladder present on that square.
For example, if the board is:
-1 1 -1
-1 -1 9
-1 4 -1
Let's say on the first move your destination square is 2 [at row 2, column 1], then you finish your first move at 4 [at row 1, column 2] because you do not continue moving to 9 [at row 0, column 0] by taking the ladder from 4.
A square can also have a Snake or Ladder which will end at the same cell.
For example, if the board is:
-1 3 -1
-1 5 -1
-1 -1 9
Here we can see Snake/Ladder on square 5 [at row 1, column 1] will end on the same square 5.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?