Approach to solve question leetcode — 17 Letter Combinations of a Phone Number
- For solving the problem recursively, we need helper function , in which digits, result and empty string (current string) will be passed as well as there will be a function which will return corresponding characters for each…
Approach to solve leetcode question- 16 3Sum Closest
- This question is somewhat similar to previous question leetcode -15 3Sum with a small change.
2. In this solution , we will take each element of array nums , and then for each element we will take two elements ahead of that…
Approach to solve leetcode question-15 3Sum
We can get all combinations of 3 elements and see their sum is equal to 0 or not and return all combinations which sums to 0, but this approach will not be efficient.
Instead we will use following approach:
- we will sort the array…
Approach to solve leetcode 12 question — Integer to Roman
- This question is quite easy to solve , we just have to declare mappings properly .
- After that, we will loop through the mapping and keep decrementing number if it exists in mapping and simultaneously adding corresponding roman into the…
Approach to solve leetcode 11 — Container With Most Water
- In this question, we are asked to calculate area between two bars, that will be calculated as (distance between bars)*(height of smaller bar).
- we will start two pointers one from start and other from end , and keep calculating area…