Google India screening round Interview question | L3 | Reject

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-10-26Added By Anonymous
Source:Ā Link
🧭 Experience: unknown āœ… Outcome: Reject šŸ’° Compensation: unknown šŸ“ Location: India šŸ¢ Company: Google šŸŽ“ Education: unknown šŸŽ Benefits: unknown šŸ“… Offer Date: unknown Q. Given two strings of equal length made up of 'x', 'y', and 'z', with no consecutive characters the same, determine the minimum number of operations needed to transform the first string into the second. In one operation, you can change any character in the first string, ensuring no consecutive characters become identical. for ex: str1: zxyz str2: zyxz zxyz → yxyz → yzyz → yzxz → zxzx → zxyz → zyxz result: 6 ex #2: str1: xyzyzyxyzx str2: xzyzyzyxzy result: 15 ex #3: str1: xyxyxyxyxy str2: xzyxyxzyxz result: 13 ex #4: str1: xyxyzyzyxy str2: zyzyxzyzyz result: 9 ex #5 str1: xzxyxyzyzyxyzx str2: zyzyxzyzyzyxzy res: 20 I tried BFS, but it will not work. The expected time complexity was linear, O(length of the string).
Comments