Problem · String

Check Pattern Presence

Learn this problem
EasyDatabricksINTERNOA

Problem statement

You are given a digit string board and an array of digit strings keys. Split every key at every possible position into a nonempty decimal index prefix and a nonempty pattern suffix.

Process keys in their given order and splits from the shortest index prefix to the longest. For each split, append the pattern when it exactly matches board starting at the decoded 0-based index; otherwise append "not found". Leading zeroes in the index prefix are allowed.

Function

checkPatternPresence(board: String, keys: String[]) → String[]

Examples

Example 1

board = "2311453915"keys = ["0211", "639"]return = ["not found", "11", "not found", "39", "not found"]

For 0211, the splits are 0|211, 02|11, and 021|1; only 02|11 matches. For 639, only 6|39 matches.

Constraints

  • 1 ≤ panel.length ≤ 103

More Databricks problems

drafts saved locally
public String[] checkPatternPresence(String board, String[] keys) {
  // write your code here
}
board"2311453915"
keys["0211", "639"]
expected["not found", "11", "not found", "39", "not found"]
checking account