Written by Array Alchemist
LeetCode wizard with 75 conquered challenges under my belt.
Turning algorithm nightmares into "Aha!" moments, one explanation at a time.
Join me to level up your coding skills – from interviews to real-world application!
Written by Array Alchemist
Solving Array question from blind 75 list.
3 years ago, this question was asked to me, in 1st round of interview at Microsoft to me and i was not able to solve. In this post we will see how we can solve it.
Two sum:
Give an array of integers like [2, 7, 11, 17] and a target 9, return the indices of two numbers in the array that add up to the target.
The most important part, why should i learn this question any way?
FANG:
Little more about Two Sum problem.
Example 1:
Given an array of integers
numsand an integertarget, return indices of the two numbers such that they add up totarget.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.
1. Optimising time using more space:
notes:
in the iteration,
2. Optimising space using more time:
we will use pointers
So this is why and how two sum leet code problem is solved.
#leetcode #computerscience #faang #problemsolving