Question
The Alchemist's Cipher Chest
A treasure vault is secured with a two-key lock. The vault contains a list of
Given the sorted rack of key numbers and the target code, find the two keys that open the vault. There is guaranteed to be exactly one valid pair. Return their positions in the rack (1-indexed).
Input
The first line contains KaTeX can only parse string typed expression. The second line contains KaTeX can only parse string typed expression space-separated integers in strictly increasing order. The third line contains the integer target.
Output
Two space-separated integers — the 1-indexed positions of the two keys.
Example
Example 1:
Input
Keys at positions 1 and 2 have values 2 and 7, which sum to 9.
Example 2:
Input
Input
4
2 7 11 15
9Output1 2ExplanationKeys at positions 1 and 2 have values 2 and 7, which sum to 9.
Example 2:
Input
3
2 3 4
6Output1 3