Recently I came across a question:
https://leetcode.com/problems/single-row-keyboard (premium)
https://codedestine.com/single-row-keyboard-string-problem/
Imagine you have a special keyboard with all keys in a single row. The layout of characters on a keyboard is denoted by a string keyboard of length 26. Initially your finger is at index 0. To type a character, you have to move your finger to the index of the desired character. The time taken to move your finger from index i to index j is abs(j - i).
Given a string keyboard that describe the keyboard layout and a string text, return an integer denoting the time taken to type string text
What if the question is modified to find the keyboard which gives the minimum time?