CODING
CODING
Problem Statement:
You are given an array of integers nums and an integer target. Find the indices of the two numbers in
the array such that they add up to the given target.
Rules:
Test Cases:
1. Input:
Output:
[0, 1]
Explanation:
nums[0] + nums[1] = 2 + 7 = 9
2. Input:
Output:
[1, 2]
3. Input:
Output:
[0, 1]
4. Input:
Output:
[2, 3]
Solution :-
num_dict = {}
if complement in num_dict:
return [num_dict[complement], i]
num_dict[num] = i
return []
Problem Statement:
You are given a string s. Find the length of the longest substring in s that does not contain any repeating
characters.
Test Cases:
1. Input:
s = "abcabcbb"
Output:
Explanation:
2. Input:
s = "bbbbb"
Output:
Explanation:
3. Input:
s = "pwwkew"
Output:
Explanation:
s = ""
Output:
Explanation:
Solutoin :-
char_set = set()
left = 0
max_length = 0
char_set.remove(s[left])
left += 1
char_set.add(s[right])