PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Solve two string problems

Last updated: Mar 29, 2026

Quick Overview

This prompt evaluates string-processing competencies: the Morse translation task tests mapping and uniqueness detection through encoding and deduplication, while the word-break task assesses segmentation and combinatorial enumeration requiring dynamic programming and memoization skills.

  • easy
  • Amazon
  • Coding & Algorithms
  • Data Engineer

Solve two string problems

Company: Amazon

Role: Data Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are asked to solve the following two coding problems. 1. **Count unique Morse code translations** You are given an array of lowercase English words, `words`. Each letter maps to standard Morse code as follows: - `a -> .-` - `b -> -...` - `c -> -.-.` - `d -> -..` - `e -> .` - `f -> ..-.` - `g -> --.` - `h -> ....` - `i -> ..` - `j -> .---` - `k -> -.-` - `l -> .-..` - `m -> --` - `n -> -.` - `o -> ---` - `p -> .--.` - `q -> --.-` - `r -> .-.` - `s -> ...` - `t -> -` - `u -> ..-` - `v -> ...-` - `w -> .--` - `x -> -..-` - `y -> -.--` - `z -> --..` The translation of a word is the concatenation of the Morse codes of its letters. For example, `"cab"` becomes `"-.-..--..."` because `c -> -.-.`, `a -> .-`, and `b -> -...`. Return the number of **distinct** word translations among all words in the input array. 2. **Return all valid word-break sentences** You are given a string `s` and a dictionary of words `wordDict`. Insert spaces into `s` to form all possible sentences such that every token is a word in `wordDict`. The same dictionary word may be reused multiple times. Return **all** valid sentences in any order. Example: - `s = "catsanddog"` - `wordDict = ["cat", "cats", "and", "sand", "dog"]` - Output: `["cats and dog", "cat sand dog"]` Design correct and efficient algorithms for both problems, and be prepared to discuss time and space complexity.

Quick Answer: This prompt evaluates string-processing competencies: the Morse translation task tests mapping and uniqueness detection through encoding and deduplication, while the word-break task assesses segmentation and combinatorial enumeration requiring dynamic programming and memoization skills.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Implement Event Filtering and Queue Routing - Amazon (medium)
  • Determine if all courses can be completed - Amazon (medium)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
Amazon logo
Amazon
Jan 24, 2026, 12:00 AM
Data Engineer
Technical Screen
Coding & Algorithms
3
0

You are asked to solve the following two coding problems.

  1. Count unique Morse code translations You are given an array of lowercase English words, words . Each letter maps to standard Morse code as follows:
    • a -> .-
    • b -> -...
    • c -> -.-.
    • d -> -..
    • e -> .
    • f -> ..-.
    • g -> --.
    • h -> ....
    • i -> ..
    • j -> .---
    • k -> -.-
    • l -> .-..
    • m -> --
    • n -> -.
    • o -> ---
    • p -> .--.
    • q -> --.-
    • r -> .-.
    • s -> ...
    • t -> -
    • u -> ..-
    • v -> ...-
    • w -> .--
    • x -> -..-
    • y -> -.--
    • z -> --..
    The translation of a word is the concatenation of the Morse codes of its letters. For example, "cab" becomes "-.-..--..." because c -> -.-. , a -> .- , and b -> -... . Return the number of distinct word translations among all words in the input array.
  2. Return all valid word-break sentences You are given a string s and a dictionary of words wordDict . Insert spaces into s to form all possible sentences such that every token is a word in wordDict . The same dictionary word may be reused multiple times. Return all valid sentences in any order. Example:
    • s = "catsanddog"
    • wordDict = ["cat", "cats", "and", "sand", "dog"]
    • Output: ["cats and dog", "cat sand dog"]

Design correct and efficient algorithms for both problems, and be prepared to discuss time and space complexity.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Data Engineer•Amazon Data Engineer•Amazon Coding & Algorithms•Data Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.