Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit db00a50

Browse files
committed
Create Blind75HintsAndExplanations.txt
1 parent 685bbd4 commit db00a50

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
BLIND 75
2+
3+
ARRAY QUESTIONS:
4+
*/------------------------------------------------------------------\*
5+
LT1. TWO SUM
6+
Question:
7+
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
8+
You may assume that each input would have exactly one solution, and you may not use the same element twice.
9+
You can return the answer in any order.
10+
11+
Example:
12+
Input: nums = [2,7,11,15], target = 9
13+
Output: [0,1]
14+
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
15+
16+
Algorithm:
17+
Since return value is an int array that stores 2 indices, create result array
18+
Create hashmap that will store key as the value at index and value and the index (k,v) = (arr[i], i)
19+
for loop to iterate O(n) i through the parameter array known as nums[]
20+
if a key with value target - nums[i] exists: where target is a paremater of the method in which we want the 2 number in nums[] to add to.
21+
result[1] = current index
22+
result[0] = value where key is target - nums[i]
23+
24+
if the statements doesn't happen
25+
put in hashmap current index where (k,v) =(nums[i], i)
26+
after iterating through all the indices return array result
27+
*/-------------------------------------------------------------------------\*
28+
LT121. Best Time to Buy and Sell Stock
29+
Question:
30+
31+
Example:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /