Google Interview Coding question

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-11-22Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown

Given two lists of Strings with the same set of elements and no duplicates within the list, find out the minimum number of contiguous swaps that are required to get from one list to another.
Example S = [B,C,A,D] and D = [C,D,A,B]

B C A D
C B A D
C A B D
C A D B
C D A B

contiguous swaps means - you can only swap adjacent elements.
Comments