Your question is Two Sum and Linked List Reversal. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
DoorDash routing utilities need two independent algorithms: identify two delivery indices whose priorities reach a target, then reverse a linked list of delivery stops. Implement both operations in one function.
Given an integer array nums, an integer target, and the head of a singly linked list, return the indices of two values that sum to target and the new head after reversing the linked list.
For JSON compatibility, each linked-list node is represented as a dictionary with keys val and next. The next value is another node dictionary or null.
Implement two_sum_and_reverse(nums, target, head).
nums is a list of integers.target is an integer.head is a linked-list node dictionary or null.two_sum, a two-element list of indices in ascending order, and reversed_head, the new linked-list head.def two_sum_and_reverse(nums, target, head):