List Consecutive Split - Google Top Interview Questions
Given a list of integers nums, and an integer k, return whether the list can be split into lists where each list contains k integers and is consecutively increasing. Constraints n ≤ 100,000 where n is the length of nums. Example 1 Input nums = [3, 2, 3, 4, 5, 1] k = 3 Output True Explanation We can split the list into [1, 2, 3] and [3, 4, 5]
View Solution →Log Truncation - Google Top Interview Questions
You are given a list of integers logs and an integer limit. Each element in logs[i] represents the size of logs generated by user i. limit represents the total size of logs you can store in your system. Return the largest x such that if we truncate every log in logs to be at most size x, the sum of the remaining log sizes is at most limit. If no log needs to be truncated, return the largest log size. Constraints 1 ≤ n ≤ 100,000 where n is the length of logs 1 ≤ limit < 2 ** 3
View Solution →Longest Arithmetic Subsequence with Difference Constraint - Google Top Interview Questions
Given a list of integers nums and an integer diff, return the length of the longest arithmetic subsequence where the difference between each consecutive numbers in the subsequence is diff. Constraints 0 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [-2, 0, 3, 6, 1, 9] diff = 3 Output 4 Explanation We can pick the subsequence [0, 3, 6, 9]. Example 2 Input nums = [9, 8, 7, 5, 3] diff = -2 Output 4 Explanation We can pick
View Solution →Longest Consecutive Sublist - Google Top Interview Questions
You are given a list of unique integers nums. Return the length of the longest sublist containing consecutive elements. Constraints 0 ≤ n ≤ 1,000 where n is the length of nums Example 1 Input nums = [1, 4, 5, 3, 2, 9] Output 5 Explanation The sublist [1, 4, 5, 3, 2] contains consecutive elements from 1 to 5.
View Solution →Longest Equivalent Sublist After K Increments - Google Top Interview Questions
You are given a list of integers nums and an integer k. Consider an operation where you increment any one element once. Given that you can perform this at most k times, return the length of the longest sublist containing equal elements. Constraints n ≤ 100,000 where n is the length of nums k < 2 ** 31 Example 1 Input nums = [2, 4, 8, 5, 9, 6] k = 6 Output 3 Explanation We can increment 8 once and 5 four times to get a sublist of [9, 9, 9].
View Solution →