Showing 11 questions
Find the longest string that is a prefix of all strings in a given array. If no common prefix exists, return an empty string.
#1. Longest Common Prefix
Find the minimum number of perfect square numbers that sum to a given integer. For example, given n = 12, return 3 because 12 = 4 + 4 + 4.
#2. Perfect Squares
Reverse a portion of a linked list. You're given the head of the list and start/end positions; reverse only the nodes between those positions.
#3. Reverse Linked List II
Find all starting indices of substrings in a string `s` that are anagrams of a given string `p`. An anagram has the same letters, rearranged.
#4. Find All Anagrams in a String
Find all the possible paths from the root to leaf nodes in a binary tree. Return each path as a string.
#5. Binary Tree Paths
You are given a sorted linked list. Remove all duplicate nodes so that each element appears only once.
#6. Remove Duplicates from Sorted List
You're given an array of numbers from 0 to n, with one number missing. Find the missing number within the array.
#7. Missing Number
Determine if a string contains a permutation of another string. In other words, check if any rearrangement of the shorter string exists as a substring within the longer string.
#8. Permutation in String
You're given two sorted lists. Combine them into a single sorted list containing all elements from both original lists.
#9. Merge Two Sorted Lists
You're given an array representing weights. Implement a function to randomly pick an index from the array, where the probability of picking each index is proportional to its weight.
#10. Random Pick with Weight
Traverse a binary tree level by level, but return the level order traversal in reverse order (bottom to top).
#11. Binary Tree Level Order Traversal II