Tip 1 : Practice competitive programming regularly
Tip 2 : Look at interview experience
Tip 3 : Talk to seniors who work there
Tip 1 : Get it reviewed by professional
Tip 2 : Mention only what you know


You only need to return the starting node for minimum and maximum slope. So if slope(P1, P2) is maximum, just return P1.
In case of more than one possible solution return the first occurring solution.
# Python program for slope of line
def slope(x1, y1, x2, y2):
if(x2 - x1 != 0):
return (float)(y2-y1)/(x2-x1)
return sys.maxint
# driver code
x1 = 4
y1 = 2
x2 = 2
y2 = 5
print "Slope is:", slope(x1, y1, x2, y2)



If the given array is: [0, 0, 1, 0, 1] The largest subarray would be: [0, 1, 0, 1] (last 4 elements) having length 4.
The brute force approach in these type of questions is to generate all the possible sub-arrays. Then firstly check whether the sub-array has equal number of 0’s and 1’s or not. To make this process easy take cumulative sum of the sub-arrays taking 0’s as -1 and 1’s as it is. The point where cumulative sum = 0 will signify that the sub-array from starting till that point has equal number of 0’s and 1’s. Now as this is a valid sub-array, compare it’s size with the maximum size of such sub-array found till now.



We can consider all substrings one by one and check for each substring whether it contains all unique characters or not. There will be n*(n+1)/2 substrings. Whether a substring contains all unique characters or not can be checked in linear time by scanning it from left to right and keeping a map of visited characters.

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?