FastPrepDelimited Morse Decoding and Word Segmentation
Problems/Delimited Morse Decoding and Word Segmentation

Delimited Morse Decoding and Word Segmentation

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives Morse text where `xxx` separates characters and `xxxxx` separates words. It then asks for all decodings when the word separator is also `xxx` and a set of words is given. Here we use standard A-Z Morse, lowercase output, and a fixed order for the sentences. Our version is about 90% the same as the reported question.

Decode an uppercase-English Morse message that uses the literal string xxx between encoded letters.

  • When sharedDelimiter is false, xxxxx separates words. Return the single decoded lowercase sentence.
  • When sharedDelimiter is true, every separator is xxx. Decode the continuous lowercase letter string, then return every sentence obtainable by splitting it into words from dictionary.

Return sentences in lexicographic order. Dictionary words are unique lowercase strings. The encoded input is valid Morse for letters A–Z. Empty input decodes to one empty sentence.

Function

decodeDelimitedMorse(encoded: String, dictionary: String[], sharedDelimiter: boolean) → String[]

Examples

Example 1

encoded = ".-xxx-..xxxxx..-"dictionary = []sharedDelimiter = falsereturn = ["ad u"]

.-, -.., and ..- decode to A, D, and U; five x characters separate the two words.

Example 2

encoded = ".-xxx-..xxx..-"dictionary = ["ad","u","a","du"]sharedDelimiter = truereturn = ["a du","ad u"]

The decoded letters are adu, which have two valid dictionary segmentations.

Example 3

encoded = ""dictionary = []sharedDelimiter = falsereturn = [""]

The empty message contains one empty sentence.

Constraints

  • 0 <= encoded.length <= 2000.
  • 0 <= dictionary.length <= 5000.
  • Dictionary words are unique lowercase English strings with length from 1 through 100.
  • At most 10000 valid sentences exist.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • First Valid Word SegmentationAmazon · ONSITE INTERVIEW
  • Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Word Break II: All SentencesMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • All Palindrome PartitionsExpedia · OAExpedia interview questions
  • Palindrome PartitioningLondon Stock Exchange · PHONE SCREENLondon Stock Exchange interview questions
  • Word Break IIWex · PHONE SCREEN
  • Word Break IIInMobi · PHONE SCREENInMobi interview questions
  • Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • Maximum Bouquet ValueOracle · ONSITE INTERVIEWOracle interview questions
  • Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[] decodeDelimitedMorse(String encoded, String[] dictionary, boolean sharedDelimiter) {
        // Write your code here.
    }
}
Checking account…