Company: Amazon_5sep

Difficulty: medium

Problem Statement

Calculate Max Distance An internal tool at a staffing team scans a long workspace log for every mention of a skill tag called expertise . You are given two strings, expertise and workspace . Look at every position where expertise occurs as a substring of workspace . Occurrences are allowed to overlap. Let first be the smallest such starting index and last be the largest such starting index, using 0 -based indexing. Report last - first . If expertise does not occur in workspace at all, report -1 . Input Format The first line contains the string expertise . The second line contains the string workspace . Output Format Print a single integer — the distance last - first between the last and the first occurrence of expertise in workspace , or -1 when expertise never occurs. Constraints 1 <= |expertise| <= 1000 1 <= |workspace| <= 190000 Both strings consist only of lowercase English letters ( a - z ), digits ( 0 - 9 ) and the underscore character _ . Neither string contains spac

More Amazon_5sep OA questionsInterview experiences