Reversed Dictionary Words
Medium
string
dictionary
reversal
substring-search
Problem Description
Given a dictionary of words and a target string, count how many dictionary words appear in the string when reversed.
Input Format
First line: target string. Second line: n (dictionary size). Next n lines: dictionary words.
Output Format
Count of dictionary words that appear reversed in the target string.
Constraints
• 1 ≤ target string length ≤ 1000
• 1 ≤ n ≤ 100
• 1 ≤ word length ≤ 50
• Case-sensitive matching
• Count each word once even if appears multiple times
Sample Input/Output
Input:
programming 3 mar gor gnimm
Output:
2
Explanation
Dictionary words reversed: "ram", "rog", "mmign". In "programming": "ram" not found, "rog" found, "mmign" not found. Wait, let me recheck...
Solution Hints
90
Points
Points
2500ms
Time Limit
Time Limit
256MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now