Prepare Interview

Mock Exams

Make Homepage

## Experienced / Expert level questions & answers

### Ques 1. Edit Distance

Given two strings, find the minimum number of operations required to convert one string into the other.

Example:

`Input: word1 = "horse", word2 = "ros", Output: 3`

### Ques 2. Palindrome Partitioning

Given a string, partition it into as many palindromic substrings as possible.

Example:

`Input: aab, Output: [['a', 'a', 'b'], ['aa', 'b']]`

### Ques 3. Count Palindromic Subsequences

Given a string, find the number of distinct palindromic subsequences of it.

Example:

`Input: "bccb", Output: 6 ("b", "c", "c", "b", "ccb", "bccb")`

### Ques 4. Longest Increasing Path in a Matrix

Given an integer matrix, find the length of the longest increasing path.

Example:

`Matrix: [[9,9,4],[6,6,8],[2,1,1]], Output: 4 (9 -> 6 -> 8 -> 1)`

### Ques 5. RegularExpression Matching

Implement regular expression matching with support for '.' and '*'.

Example:

`Input: s = "aa", p = "a*", Output: true`

### Ques 6. Maximum Profit with K Transactions

Given an array representing stock prices, find the maximum profit that can be obtained with at most k transactions.

Example:

`Input: [3, 2, 6, 5, 0, 3], k = 2, Output: 7`

### Ques 7. Count Distinct Subsequences

Given a string, find the number of distinct non-empty subsequences of the string.

Example:

`Input: "abc", Output: 7 ("a", "b", "c", "ab", "ac", "bc", "abc")`

### Ques 8. Word Break II

Given a non-empty string and a dictionary of words, return all possible sentences formed by concatenating words from the dictionary.

Example:

`Input: s = "catsanddog", wordDict = ["cat", "cats", "and", "sand", "dog"], Output: ["cats and dog", "cat sand dog"]`

### Ques 9. Word Ladder II

Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequences from beginWord to endWord.

Example:

`beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"], Output: [["hit","hot","dot","dog","cog"],["hit","hot","lot","log","cog"]]`