Problem · String

Count Element Symbol Decompositions

Learn this problem
MediumGoogleFULLTIMEPHONE SCREEN
See Google hiring insights

Problem statement

Given a collection of chemical element symbols symbols and a word word, return the number of ways to split the entire word into a sequence of the supplied symbols.

Symbol matching is case-insensitive.

Function

countElementSymbolDecompositions(symbols: String[], word: String) → int

Examples

Example 1

symbols = ["P", "H", "Y", "S", "I", "C", "Si", "Cs"]word = "Physics"return = 4

The four decompositions are P-H-Y-Si-C-S, P-H-Y-Si-Cs, P-H-Y-S-I-C-S, and P-H-Y-S-I-Cs.

More Google problems

drafts saved locally
public int countElementSymbolDecompositions(String[] symbols, String word) {
  // Write your code here.
}
symbols["P", "H", "Y", "S", "I", "C", "Si", "Cs"]
word"Physics"
expected4
checking account