FastPrepMinimum Steps on a Circular Character Dial
Problems/Minimum Steps on a Circular Character Dial

Minimum Steps on a Circular Character Dial

Navan logoNavan● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Navan onsite interview for a full-time role. The task asks for the minimum movement from a given starting index on a circular character array. We chose the visiting rules, the cost of one step, what happens when a character is missing, the ASCII limits, and the function interface.

Our version is about 80% the same as the reported question.

You are given a circular array of characters as ring, a starting index startIndex, and a target string. Moving clockwise or counterclockwise to an adjacent ring position costs one step.

For this exercise, assume you must visit the target characters in order. Visiting a character costs no extra selection step. The ring may contain duplicate characters, and you may choose any occurrence when visiting the next target character. Return the minimum total movement cost, or -1 if a target character is absent. An empty target costs zero steps.

Function

calculateMinSteps(ring: String, startIndex: int, target: String) → int

Examples

Example 1

ring = "ABCDEF"startIndex = 2target = "FA"return = 4

From C at index 2, reach F in three moves in either direction, then A in one move. The total is four.

Example 2

ring = "ABACA"startIndex = 1target = "AC"return = 2

Choose A at index 2, one step from B, then C at index 3 in one more step. Choosing A at index 0 would cost more before the following C.

Example 3

ring = "XYZ"startIndex = 2target = "A"return = -1

A does not occur on the supplied ring.

Constraints

  • 1 <= ring.length <= 100.
  • 0 <= startIndex < ring.length.
  • 0 <= target.length <= 100.
  • For this exercise, assume ring and target characters are ASCII letters and digits.

More Navan interview questions

  • Time Based Key-Value StoreONSITE INTERVIEW · Seen Dec 2025
  • Type-Ahead Prefix MatchesONSITE INTERVIEW · Seen Dec 2024
  • Minimum Stick Connection CostONSITE INTERVIEW · Seen Jan 2024
  • Shortest Substring with at Least K Distinct CharactersONSITE INTERVIEW · Seen Jan 2024
  • Compare N-Ary Tree Leaf SequencesONSITE INTERVIEW · Seen Nov 2023
  • Roman to IntegerPHONE SCREEN · Seen Oct 2024
  • Sort ColorsPHONE SCREEN · Seen Oct 2024
  • Basic CalculatorPHONE SCREEN · Seen Jun 2024
  • LRU CachePHONE SCREEN · Seen Jun 2024
  • House RobberPHONE SCREEN · Seen May 2024

Similar questions at other companies

  • Maximum Bouquet ValueOracle · ONSITE INTERVIEWOracle interview questions
  • Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word BreakGoogle · ONSITE INTERVIEWGoogle interview questions
  • Reconstruct One Sentence From a DictionaryMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Scramble StringExpedia · ONSITE INTERVIEWExpedia interview questions
  • Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
  • Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Decode Numeric StringArcesium · ONSITE INTERVIEWArcesium interview questions
  • Word BreakBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Count Vowel PermutationsZscaler · ONSITE INTERVIEWZscaler interview questions
All Navan interview questionsSee Navan hiring insights
Saved
class Solution {
    public int calculateMinSteps(String ring, int startIndex, String target) {
        // write your code here
    }

}
Checking account…