Dream Job
Google Job
Big Techs
Step 1: Verify the constraints
- If given a list of numbers, one can ask, "Are all numbers positive or can there be negatives?"
- "Are there duplicate numbers in the list?"
- "Will there always be a solution available?"
- "Can there be more than one solution?"
- "What do we return if there's no solution?"
Step 2: Write out some test cases
- In this step, it is good to work with interviewer.
- You may ask, "Is it okay if we come up with some test cases together that best capture the solution we seek?".
Step 3: Figure out a solution on paper
Step 4: Code the solution
Step 5: Test the solution
Step 6: Analyzing the space and time complexity
Step 7: Can the solution be optimized further?
Easy
category:Arrays
Given an array of integers nums
and an integer target
, return indices of the two numbers such that they add up to target
.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Medium
category:Arrays
Medium
category:Arrays
Given n
non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n
vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
Abhishek Dev