Showing 97 questions
Determine if a number is a 'happy number'. A happy number eventually reaches 1 when replaced by the sum of the squares of its digits, repeating the process until it does.
#1. Happy Number
You're given a list of jobs with start times, end times, and profits. Find the maximum profit you can obtain by scheduling a subset of jobs that don't overlap.
#2. Maximum Profit in Job Scheduling
You are given k sorted lists. Combine all of their elements into a single sorted list and return it.
#3. Merge k Sorted Lists
You're given courses with prerequisites and time to complete each. Find the minimum time to finish all courses, taking dependencies and parallel study into account.
#4. Parallel Courses III
You are given a list of events with start times, end times, and values. Determine the maximum total value you can obtain by attending at most 'k' events, without any overlapping events.
#5. Maximum Number of Events That Can Be Attended II
Implement an in-memory file system with basic operations like creating directories, adding files, and listing contents. The file system should support path-based navigation.
#6. Design In-Memory File System
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.
#7. Course Schedule II
You are given a board of characters and a list of words. Find all the words from the list that can be formed by traversing adjacent cells on the board.
#8. Word Search II
Find the smallest substring within a larger string that contains all the characters of a target string. You need to locate the minimum window that satisfies this condition.
#9. Minimum Window Substring
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.
#10. Find All Anagrams in a String
Determine if one string can be transformed into another by repeatedly moving a character to the beginning of the string. Return the minimum number of moves required, or -1 if it's impossible.
#11. String Transformation
You're given a person's income and tax brackets with corresponding rates. Calculate the total amount of tax they need to pay based on their income and the tax brackets.
#12. Calculate Amount Paid in Taxes
Imagine navigating a binary tree. Find the shortest path, represented as a sequence of directions ('U', 'L', 'R'), from one specific node to another.
#13. Step-By-Step Directions From a Binary Tree Node to Another
You're given servers with varying CPU requirements and a limited budget to upgrade them. Determine the maximum number of servers you can upgrade within the budget, considering different upgrade tiers.
#14. Maximum Number of Upgradable Servers
Given an array representing the height of bars, calculate how much water can be trapped between them after rain. Think about finding the maximum height to the left and right of each bar.
#15. Trapping Rain Water
You are given a sequence of numbers. Find the longest subsequence that satisfies a specific 'good' condition related to divisibility.
#16. Find the Maximum Length of a Good Subsequence I
You need to paint several walls. You can either pay a painter or use your free painting skills, each having different costs and time. Determine the minimum cost to paint all the walls.
#17. Painting the Walls
You're given an array of numbers. Find the minimum possible length of the array after repeatedly removing pairs of equal numbers.
#18. Minimum Array Length After Pair Removals
You're given a sequence of numbers and need to find the longest subsequence that satisfies a specific 'good' condition defined by its elements. The definition of a 'good' sequence is provided in the detailed problem description.
#19. Find the Maximum Length of a Good Subsequence II
You're given a dictionary of words and a target string. Find the number of ways to construct the target string by picking characters from the words in the dictionary at each position.
#20. Number of Ways to Form a Target String Given a Dictionary