For an mthree engineering assessment, implement two independent array operations in one function: find two indices whose values sum to a target, and locate a value in a rotated sorted array.
Implement solve_queries(nums, target_sum, rotated_nums, search_target):
nums, return the indices of the two distinct elements whose values add to target_sum. Return indices in increasing order.rotated_nums, return the index of search_target, or -1 if it is absent. rotated_nums was created by rotating a strictly increasing sorted array at an unknown pivot.Return a dictionary with exactly these keys: two_sum and rotated_index. The input guarantees exactly one valid pair for the first operation.
Example 1
Input: nums = [2, 7, 11, 15], target_sum = 9,
rotated_nums = [6, 7, 0, 1, 2, 4, 5], search_target = 0
Output: {"two_sum": [0, 1], "rotated_index": 2}
The values at indices 0 and 1 sum to 9, and 0 occurs at index 2 in the rotated array.
Example 2
Input: nums = [-3, 4, 3, 90], target_sum = 0,
rotated_nums = [30, 40, 5, 10, 20], search_target = 25
Output: {"two_sum": [0, 2], "rotated_index": -1}
The pair -3 + 3 equals 0, while 25 does not appear in the rotated array.
2 <= len(nums) <= 10^51 <= len(rotated_nums) <= 10^5-10^9 <= nums[i], target_sum, rotated_nums[i], search_target <= 10^9rotated_nums are distinct.rotated_nums is a rotation of a strictly increasing array.def solve_queries(nums, target_sum, rotated_nums, search_target):