Company: sony_8thaug

Difficulty: easy

Problem Statement

Count Distinct Date Patterns in Text A log processor scans free-form text looking for anything that is written like a date. You are given a single line of text S . A date pattern is a block of exactly 10 consecutive characters of S that has the shape XX-YY-ZZZZ that is: two digits, a hyphen - , two digits, a hyphen - , then four digits. A digit is one of the characters 0 – 9 . Count how many distinct date patterns occur in S . Two occurrences are the same date pattern when the two 10 -character blocks are identical character for character. Input Format A single line containing the text S . S may contain spaces in the middle, so read the entire line rather than splitting it into tokens. The trailing newline is not part of S . Output Format Print a single integer — the number of distinct date patterns in S . Constraints 1 <= length of S <= 100000 Every character of S is a printable ASCII character with code between 32 and 126 inclusive. The answer is at most length of S , so it fit

More sony_8thaug OA questionsInterview experiences