Tip 1 : Do some basic research about the interview process and types of rounds while appearing for a company interview. Narrow down the topics and draft a realistic plan afterwards.
Tip 2 : Try to solve as many problems as possible topic wise.
Tip 3 : Please cover the breadth of topics first to get an early estimate of strong and weak topics.
Tip 1 : Tailor your resume as per expectations from the role you are applying for.
Tip 2 : Order your experiences and skills by relevance.
Tip 3 : Try to fit the content in a single page.
1. You can not slant the container i.e. the height of the water is equal to the minimum height of the two lines which define the container.
2. Do not print anything, you just need to return the area of the container with maximum water.
For the above Diagram, the first red marked line is formed between coordinates (2,0) and (2,10), and the second red-marked line is formed between coordinates (5,0) and (5,9). The area of water contained between these two lines is (height* width) = (5-2)* 9 = 27, which is the maximum area contained between any two lines present on the plane. So in this case, we will return 3* 9=27.
Strings ‘STR’ and ‘PTR’ consist only of English uppercases.
Length of string ‘STR’ will always be greater than or equal to the length of string ‘PTR’.
The index is ‘0’ based.
In case, there is no anagram substring then return an empty sequence.
For example, the given ‘STR’ is ‘BACDGABCD’ and ‘PTR’ is ‘ABCD’. Indices are given
0-3 in ‘STR’ index 0,1,2,3 are ‘BACD’ and it is an anagram with ‘ABCD’
1-4 in ‘STR’ index 1,2,3,4 are ‘ACDG’ and it is not anagram with ‘ABCD’
2-5 in ‘STR’ index 2,3,4,5 are ‘CDGA’ and it is not anagram with ‘ABCD’
3-6 in ‘STR’ index 3,4,5,6 are ‘DGAB’ and it is not anagram with ‘ABCD’
4-7 in ‘STR’ index 4,5,6,7 are ‘GABC’ and it is not anagram with ‘ABCD’
5-8 in ‘STR’ index 5,6,7,8 are ‘ABCD’ and it is an anagram with ‘ABCD’
Hence there are 2 starting indices of substrings in the string ‘STR’ that are anagram with given ‘PTR’ which are index 0 and 5.
In the above image, areas in green, red, and violet color are all submatrices of the original 4x4 matrix.
1. Binary valued matrix has only two values in each cell : 0 and 1.
2. A submatrix is a matrix formed by selecting certain rows and columns from a larger matrix.
3. The area of a matrix with 'h' rows and 'w' columns is equal to 'h' * 'w'.
1) In general, for an array of size 'N', there are (2 ^ 'N' - 1) non-empty subsequences possible. Because we are not considering empty subsequence for this problem.
2) The array may contain duplicate elements.
3) X mod 10 ^ 9 + 7 is the remainder when X is divided by 10 ^ 9 + 7.
1. Brute force approach is to check all subsequences in O(2^N)
2. Suggested on dynamic programming based approach - maintain 2 arrays odd and even which stores number of odd subsequences and num of even subsequences respectively till index i.
3. Logic to get ith value: if ith element is odd, ith value of odd array is sum of i-1 th value of odd array, i-1 th value of even array and 1. Similarly ith value of even array is sum of 2 x (i-1 th val of even array) and 1.
4. Optimized memory by using 2 variables instead of arrays for odd, even counts.
Note that the given operation will be performed only 'N'-1 times, where 'N' is the size of the given array.
If the given array is [1, 3, 2], then you need to return [3, -1, -1]. Because for 1, 3 is the next greater element, for 3 it does not have any greater number to its right, and similarly for 2.
1. Analysed the problem and clarified the assumption with input sizes and data types
2. Found out the given problem was a variation of next greater element (link above)
3. Used stack data structure to solve it in O(N) time.
Design a least frequently used cache. (Practice)
1. Specify data structures, read/write method logic
2. Handle concurrency and failure scenarios
3. High level system design discussion
Tip 1: Revise general distributed system concepts thoroughly.
Tip 2: Practice as many design problems as possible with time constraints. Try to discuss approaches with friends.
Tip 3: Clarify as many doubts and assumptions as possible wit h the interviewer before jumping to the solution.
Tip 4: While solving low level design problems, do consider concurrency scenarios and failure scenarios.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you create a function in JavaScript?