Solve common string and subarray problems
LinkedInSoftware Engineer · Technical ScreenLast updated
Assesses core string and array manipulation skills by requiring string reversal and contiguous-subarray computations for maximum sum and maximum product, identified under the Coding & Algorithms category.
You are given three coding tasks:
- Reverse a string
- Input: a string
s. - Output: the string with characters in reverse order.
- Maximum sum of a contiguous subarray
- Input: an integer array
nums(may contain negative numbers). - Output: the maximum possible sum of any non-empty contiguous subarray.
- Example:
[-2,1,-3,4,-1,2,1,-5,4]→6(subarray[4,-1,2,1]).
- Maximum product of a contiguous subarray
- Input: an integer array
nums(may contain negative numbers and zeros). - Output: the maximum possible product of any non-empty contiguous subarray.
- Example:
[2,3,-2,4]→6(subarray[2,3]).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.