A Citigroup transaction-monitoring component must locate a transaction amount in a sorted list and reverse a related reference string for downstream formatting. Implement both operations in one function.
Given a sorted list of integers amounts, an integer target, and a string reference, return a two-element list containing the index of target in amounts, or -1 if it is absent, followed by reference reversed character by character.
Use binary search for the lookup. If duplicate target values exist, returning any matching index is valid. Reverse the string without calling a built-in reverse helper.
amounts, a non-decreasing list of integers; target, an integer; and reference, a string.[index, reversed_reference], where index is a valid matching position or -1, and reversed_reference is the input string in reverse order.def search_and_reverse(amounts, target, reference):