Onehouse logo

Onehouse · OA

In process

Onehouse.ai OA Technical Screen

Software engineer · Full-time5 years experienceBachelor's degreeNov 2026
Shared byFastPrep fren

Applied on LinkedIn, received a link from the recruiter for the OA a couple weeks after.

OA had one question, 1D DP, similar to Word Search on Leetcode


Spell Fragmentation Decoder

You have discovered an ancient magical scroll containing a long continuous string encodedString of mysterious characters. This string encodes a sequence of magical words that must be deciphered by splitting it into valid fragments. Fortunately, you also have a dictionary of known magical words that can help decode the scroll.

Your goal is to break the string into valid words using the dictionary and maximize the number of such words formed. Each time you find a word from the dictionary in the string (as a contiguous fragment), you may include it and continue recursively on the remaining part of the string.

Function Description

You need to implement the function maxWordsDecrypted to find the maximum number of valid words the string can be split into, using only the words in the dictionary.

Parameters:

  • encodedString (String): A string representing the encoded magical text. The length of this string is between 1 ≤ length(encodedString) ≤ 100,000.
  • dictionarySize (Int): An integer n representing the size of the dictionary. The value of n is between 1 ≤ n ≤ 30,000.
  • wordDict (List of Strings): A list of strings where each string represents a valid magical word in the dictionary. The length of each word is between 1 ≤ length(word) ≤ 100.

Return:

  • An integer representing the maximum number of valid words the string can be broken into using words from the dictionary.

Input Format:

  1. The first line contains a string encodedString (1 ≤ length of encodedString ≤ 100,000).
    (Remaining input lines for dictionarySize and wordDict are cut off below the scroll in the image.)

Sample Input 1 (from the right pane)

aaaa
1
a
0 total reactions. Your reactions: none.
0 comments

Comments

0

No comments yet — be the first to share what you know.