- Resizing Arrays is expensive
Delete Middle Node of a Linked List
Remove Duplicates from Sorted List
Priority: High
- Time Complexity: O(n log log n)
- Space Complexity: O(n)
- Used to find all prime numbers up to a given limit
function sieveOfEratosthenes(n) {
const isPrime = new Array(n + 1).fill(true);
isPrime[0] = isPrime[1] = false;
for (let i = 2; i * i <= n; i++) {
if (isPrime[i]) {
for (let j = i * i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
const primes = [];
for (let i = 2; i <= n; i++) {
if (isPrime[i]) {
primes.push(i);
}
}
return primes;
} Priority: High
Priority: High
Find Index of First Occurence in a String
Priority: High
Distinct Numbers in Each Subarray
- Time Complexity: O(n)
- Space Complexity: O(n)
- Used to find the number of distinct numbers in each subarray
Priority: High
Priority: High