LeetCode ✅😎😎

Popular LeetCode questions you must solve ✅😎😎

How did I select the below questions?

Let's first focus on solving these questions. I selected them from various places including Udemy courses where they had marked these as popular questions. So, I'm sure these would help me a lot.

How to select Leetcode questions for interviews?

Read Algo monster blog below

Questions I would solve. This list will increase as I go and I keep adding the new questions and also the info where I found it saying they are useful.

Questions (E- Easy, M-Med, H-Hard)

Topics

Who said this is important

283 (E), 881(M), 941 (E), 11(M), 3(M), 34(M), 278(E)

Arrays and Strings(Includes Google asked)

268(E), 204(E), 136(E), 657(E)

Math(Includes Microsoft asked)

1(E), 217(E), 169(E), 49(M), 454(M), 146(M), 76(H)

Hashtables / Maps(Includes Facebook asked)

21(E), 141(E), 206(E), 2(M), 19(M), 328(M), 23(H)

Linked List (Includes Amazon asked)

78(M), 17(M), 79(M), 39(M), 131(M)

Backtracking (Includes Uber asked)

101(E), 104(E), 112(E), 236(M), 230(M), 297(H), 124(H)

Trees and Graphs(Includes Apple asked)

155(E), 20(E), 102(M), 103(M), 145(M)

Stacks and Queues(Includes Bloomberg asked)

198(E), 121(E), 70(E), 322(M), 62(M), 5(M), 42(H), 42(H)

Dynamic Programming(Includes Google asked)

Amazon LeetCode Questions (72 questions)

Video Explanation

1. Two Sum - Easy (Array)

array | hash-table

2. Add Two Numbers - Medium (Linked List)

linked-list | math

3. Longest Substring without repeating characters - Medium (Strings)

hash-table | two-pointers | string | sliding-window

const matrix = []
const str = "babad";
let count = 0;
let palindromes = [];
let longestPal = "" // longest palindromic substring

for (const ch of str) {
    matrix.push(new Array(str.length).fill(0))
}
//set diagonals to 1
for (let diag = 0; diag < str.length; diag++) {
    matrix[diag][diag] = 1
}

//set 1 in grid above diagonal
for (let col = 1; col < str.length; col++) {
    for (row = 0; row < col; row++) {
        if (row === col - 1 && str[row] === str[col]) {
            matrix[row][col] = 1
            count++;
            palindromes.push(str.slice(row, col + 1))
            if (str.slice(row, col + 1) > longestPal.length) {
                longestPal = str.slice(row, col + 1)
            }
        } else if (matrix[row + 1][col - 1] === 1 && str[row] === str[col]) {
            matrix[row][col] = 1
            count++;
            palindromes.push(str.slice(row, col + 1))
            if (str.slice(row, col + 1).length > longestPal.length) {
                longestPal = str.slice(row, col + 1)
            }
        }
    }
}
// (0,2) -> (1,1) -> (row=0,col=2) chk for (row=1,col=1)
const printMatrix = () => {
    for (let row = 0; row < str.length; row++) {
        let rowStr = ''
        for (let col = 0; col < str.length; col++) {
            rowStr += matrix[row][col] + (col !== str.length - 1 ? " | " : "")
        }
        console.log(`${row}       | ${rowStr} |`)
        console.log("-".repeat(23).padStart(30, " "))
    }
}

printMatrix()
console.log(palindromes) // all the palindromes
console.log(`The longest palindrome is ${longestPal}`) // longest palindrome

Last updated