DSA Task 1 - Reverse Prefix Sum
Given:
Prefix Sum Example:
n = 0
ll = []
for i in range(len(l)):
n += l[i]
ll.append(n)
print(ll)
Output:
Task
Find the Reverse Prefix Sum.
For each index, calculate:
sum of current element + all elements to its right
Example
Input:
Output:
Hint
27 = 1+2+4+5+7+8
26 = 2+4+5+7+8
24 = 4+5+7+8
...
DSA Task 2 - Frequency Count Without Counter
Given:
l = [1, 2, 3, 4, 5, 5, 1]
Using Counter:
from collections import Counter
print(Counter(l))
Output:
{1: 2, 2: 1, 3: 1, 4: 1, 5: 2}
Task
Find the frequency of each element without using Counter.
Expected Output
{
1: 2,
2: 1,
3: 1,
4: 1,
5: 2
}
Rules
- Do not use
Counter
- Use dictionary only
- Use loops
Day 15 - Arrays: Basics & Two Pointers
Question 1: Prefix Sum
Given:
Create a prefix sum array.
Expected Output
Question 2: Two Pointers
Given a sorted array:
arr = [1, 2, 3, 4, 6, 8]
target = 10
Find if there exists a pair whose sum equals the target.
Expected Output
Day 16 - Arrays: Medium Patterns
Question 1: Rotate Array Right by K
Given:
arr = [1, 2, 3, 4, 5]
k = 2
Rotate the array to the right by k positions.
Expected Output
Question 2: Merge Two Sorted Arrays
Given:
arr1 = [1, 3, 5]
arr2 = [2, 4, 6]
Merge them into a single sorted array.
Expected Output
Day 17 - Strings: Pattern Problems
Question 1: Reverse Words in a String
Given:
Reverse the order of words.
Expected Output
Question 2: Check Anagram
Given:
s1 = "listen"
s2 = "silent"
Check whether both strings are anagrams.
Expected Output
Day 18 - Strings / Sliding Window
Question 1: Longest Substring Without Repeating Characters
Given:
Find the length of the longest substring without repeating characters.
Expected Output
Explanation
DSA Task 1 - Reverse Prefix Sum
Given:
Prefix Sum Example:
Output:
Task
Find the Reverse Prefix Sum.
For each index, calculate:
Example
Input:
Output:
Hint
DSA Task 2 - Frequency Count Without Counter
Given:
Using Counter:
Output:
{1: 2, 2: 1, 3: 1, 4: 1, 5: 2}Task
Find the frequency of each element without using Counter.
Expected Output
{ 1: 2, 2: 1, 3: 1, 4: 1, 5: 2 }Rules
CounterDay 15 - Arrays: Basics & Two Pointers
Question 1: Prefix Sum
Given:
Create a prefix sum array.
Expected Output
Question 2: Two Pointers
Given a sorted array:
Find if there exists a pair whose sum equals the target.
Expected Output
Day 16 - Arrays: Medium Patterns
Question 1: Rotate Array Right by K
Given:
Rotate the array to the right by
kpositions.Expected Output
Question 2: Merge Two Sorted Arrays
Given:
Merge them into a single sorted array.
Expected Output
Day 17 - Strings: Pattern Problems
Question 1: Reverse Words in a String
Given:
Reverse the order of words.
Expected Output
Question 2: Check Anagram
Given:
Check whether both strings are anagrams.
Expected Output
Day 18 - Strings / Sliding Window
Question 1: Longest Substring Without Repeating Characters
Given:
Find the length of the longest substring without repeating characters.
Expected Output
Explanation