Your question is Reverse String and Binary Search. 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.
AVEVA engineering tools may need to display a reversed identifier while efficiently locating a value in an ordered collection. Implement both operations in a single function.
Given a string text, a sorted list of distinct integers values, and an integer target:
text reversed.target in values, or -1 if the target is absent.The list values is sorted in ascending order. Do not use Python's list.index(), in, bisect, or any library search function for the lookup. The string reversal may use a loop or Python slicing.
text, a string; values, a sorted list of distinct integers; and target, an integer.[reversed_text, index], where reversed_text is a string and index is the target's position or -1.def reverse_and_search(text, values, target):