As reported: Visa Senior Data Scientist (Bengaluru), round 1 — coding in SQL and Python (2025). Python: given a list of valid words that may be used in variable names and a CamelCase string (which may or may not start with a capital letter), decide whether the string can be split into words that all exist in the list; matching is case-insensitive. Example list:
["my","variable","name","parse","json","data"].
Given validWords and a variable name name, return true if name can be split into a sequence of one or more words, each of which is in validWords (ignoring letter case), and false otherwise. Words may be reused.
This is LeetCode 139 — Word Break with case-insensitive matching.
Example
validWords = ["my","variable","name","parse","json","data"]
name = "myVariableName" -> true (my | Variable | Name)
name = "ParseJsonData" -> true
name = "myVarName" -> false ("Var" is not a valid word)
Constraints: 1 ≤ validWords.length ≤ 1000; 1 ≤ word length ≤ 20; 1 ≤ name.length ≤ 300; only English letters.
Clarifications
- Case is ignored everywhere:
"MYNAME"splits asmy | name. - A split may fall anywhere, not only before a capital letter.
Code runner format: one JSON value per line: validWords, then name. Implement canSplit(validWords, name); the harness prints true or false.