Showing 21 questions
Find the contiguous subarray within a given array of numbers which has the largest product. The array can contain negative numbers, so you need to account for both maximum and minimum values.
#1. Maximum Product Subarray
You're given a starting score and a target score. Determine the minimum number of moves (either incrementing or doubling your score) to reach the target.
#2. Minimum Moves to Reach Target Score
Find the largest magic square within a given matrix. A magic square has equal sums across rows, columns, and both diagonals.
#3. Largest Magic Square
Given a string, find the maximum number of times the word "balloon" can appear as a subsequence using the letters from the input string.
#4. Maximum Number of Balloons
Find the best pair of sightseeing spots in an array to maximize a score calculated from their values and distance. The score is the sum of the two spots' values minus the distance between them.
#5. Best Sightseeing Pair
Construct the longest possible string using limited quantities of 'a', 'b', and 'c', ensuring that no three consecutive characters are the same. Return the longest string satisfying this constraint.
#6. Longest Happy String
You're given employee names, key-card access times, and need to identify employees who used the same key-card three or more times within a one-hour period. Return these employees in sorted order.
#7. Alert Using Same Key-Card Three or More Times in a One Hour Period
Design a leaderboard that can track player scores, update individual scores, and retrieve the top k scores efficiently. You need to implement methods for adding scores, updating scores, and getting the top k scores.
#8. Design A Leaderboard
You are given a string. Remove characters so that no three consecutive characters are the same. Return the resulting string.
#9. Delete Characters to Make Fancy String
You are given two non-negative integers represented as strings. Your task is to add these two strings together and return the sum, also as a string.
#10. Add Strings
Given a string of digits, count the number of substrings that are divisible by a given number. Each substring should be interpreted as an integer.
#11. Number of Divisible Substrings
Given a list of words, group together all the anagrams. Anagrams are words that contain the same letters rearranged.
#12. Group Anagrams
Find the longest palindromic substring within a given string. A palindromic substring reads the same forwards and backward.
#13. Longest Palindromic Substring
Determine if a given string is a palindrome, considering only alphanumeric characters and ignoring cases. Essentially, check if the string reads the same forwards and backward after removing non-alphanumeric characters and converting to lowercase.
#14. Valid Palindrome
Starting from (0, 0), can you reach a target point (tx, ty) by repeatedly applying the transformation (x, y) -> (x, x+y) or (x, y) -> (x+y, y)? Determine if it's possible.
#15. Reaching Points
Reverse the order of words in a given string. The input string may contain leading or trailing spaces, which should be removed in the output.
#16. Reverse Words in a String
Find the maximum number of vowel letters within any substring of a given length from a larger string. The goal is to slide a window of fixed size across the string and count vowels.
#17. Maximum Number of Vowels in a Substring of Given Length
Find the number of palindromic substrings within a given string. Consider each single character and repeated characters as a substring.
#18. Palindromic Substrings
Find the length of the longest strictly increasing subsequence within a given array of numbers. A subsequence doesn't need to be contiguous, but the elements must maintain their original order.
#19. Longest Increasing Subsequence
Find the maximum value within each sliding window of a given size as it moves across an array.
#20. Sliding Window Maximum