Your question is LeetCode Hard SQL. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
KPIT's engineering knowledge search surface stores indexed text and a required set of equal-length keywords. Write a PostgreSQL query that finds every zero-based character position where the text contains all required keywords exactly once, in any order and including duplicate keyword requirements.
case_id and the zero-based start_position for every valid match.word_count * word_length characters.case_id and start_position.NULL search text.All keywords within a case have the same length.
| Column | Type | Description |
|---|---|---|
| case_idPK | INT | Search case identifier |
| search_text | TEXT | Text scanned for concatenated keywords |
| case_label | VARCHAR(80) | Short description of the search case |
| Column | Type | Description |
|---|---|---|
| word_idPK | INT | Required-word identifier |
| case_id | INT | References search_cases.case_id |
| word_position | INT | Position in the input requirement list |
| word_text | VARCHAR(40) | Keyword that must occur in the candidate substring |