Showing 42 questions
Given a string of digits, find all possible valid IP address combinations you can create by inserting dots. An IP address is valid if each segment is between 0 and 255.
#1. Restore IP Addresses
You're given a string of characters and a limit on how many times each character can repeat consecutively. Build the lexicographically largest string possible while respecting this repeat limit.
#2. Construct String With Repeat Limit
In a town, find the 'judge' who is trusted by everyone else but doesn't trust anyone. You are given trust relationships; determine if a town judge exists and, if so, who they are.
#3. Find the Town Judge
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.
#4. Reverse Linked List II
Reverse a linked list in groups of k nodes. If the number of nodes is not a multiple of k, leave the remaining nodes at the end as is.
#5. Reverse Nodes in k-Group
Rearrange a linked list so that its nodes alternate between the beginning and end of the original list. You'll essentially be merging the first half and the reversed second half of the list.
#6. Reorder List
Find the inorder successor of a given node in a binary search tree. The tree has parent pointers, allowing you to traverse upwards.
#7. Inorder Successor in BST II
Determine if there are any duplicate numbers in an array where the indices of these duplicates are within a certain distance of each other. Specifically, check if any two equal numbers exist in the array, where their indices differ by at most k.
#8. Contains Duplicate II
Determine how many numbers from 1 to N are considered 'good'. A number is 'good' if, after rotating each digit individually by 180 degrees, the result is a valid number different from the original.
#9. Rotated Digits
You're given a sorted array that has been rotated, and a target value. Find the index of the target value in the rotated array, or return -1 if it's not present.
#10. Search in Rotated Sorted Array
Given a linked list and a value, remove all nodes from the linked list that have the given value. Return the modified linked list.
#11. Remove Linked List Elements
Design a data structure that acts as a Least Recently Used (LRU) cache. Implement methods to get and put key-value pairs, evicting the least recently used entry when the cache is full.
#12. LRU Cache
You're given a list of courses and their prerequisites. Determine a valid order in which you can take all the courses, respecting the dependencies. If it's impossible to finish all courses, indicate that.
#13. Course Schedule II
You're given a sorted array of unique integers and need to find the k-th missing number starting from the leftmost element. Figure out which element is missing and return it.
#14. Missing Element in Sorted Array
Find the maximum sum of any path in a binary tree, where a path can start and end at any node. The path must contain at least one node.
#15. Binary Tree Maximum Path Sum
You're given different box types, each containing a certain number of units. Determine the maximum number of units you can load onto a truck with a limited size.
#16. Maximum Units on a Truck
You're given two sorted lists. Combine them into a single sorted list containing all elements from both original lists.
#17. Merge Two Sorted Lists
You're given an array of numbers from 0 to n, with one number missing. Find the missing number within the array.
#18. Missing Number
Design a data structure to calculate the moving average of a stream of numbers. You'll need to efficiently update the average as new numbers arrive and old ones expire based on a window size.
#19. Moving Average from Data Stream
Find the inorder successor of a given node in a Binary Search Tree (BST). The inorder successor is the node with the smallest key greater than the given node's key.
#20. Inorder Successor in BST