FastPrepPassword From Ordering Hints
Problems/Password From Ordering Hints

Password From Ordering Hints

Rogo logoRogo● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: A human-submitted Rogo onsite report dated August 4, 2026 describes deducing a password from several hints and explicitly relates it to Alien Dictionary. This version states the adjacent ordering edges, lexicographic tie rule, uniqueness, and cycle outcome needed for deterministic judging.

Each string in hints lists distinct password characters in their required relative order. The password contains every distinct character that appears in any hint exactly once.

Return the lexicographically smallest password consistent with every hint. Return the empty string when the hints contain a cycle and no valid password exists.

Function

deducePassword(hints: String[]) → String

Examples

Example 1

hints = ["wrt","wrf","er","ett","rftt"]return = ""

Combining adjacent constraints yields the unique order wertf.

Example 2

hints = ["ab","ba"]return = ""

The two hints require both a before b and b before a.

Constraints

  • 1 <= hints.length <= 10000
  • Each hint contains 1 to 62 distinct letters or digits.
  • At most 62 distinct characters appear overall.
See Rogo hiring insights
Saved
class Solution {
    public String deducePassword(String[] hints) {
      // Write your code here.
    }

}
Checking account…