Interesting Array | Coursera
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2020-04-25Added By Anonymous
Source: Link
Company: Coursera
Role: unknown
Interview Stage: unknown
Location: unknown
Year: unknown
Original Content:
You are given a sequence A1,A2,…,AN and an integer K. You may perform any number of operations of the following type (in any order): choose a valid integer i and swap Ai with Ai+K. Can you sort the sequence this way? Example Input 2 4 1 1 4 2 3 4 2 1 4 2 3 Example Output yes no
Role: unknown
Interview Stage: unknown
Location: unknown
Year: unknown
Original Content:
You are given a sequence A1,A2,…,AN and an integer K. You may perform any number of operations of the following type (in any order): choose a valid integer i and swap Ai with Ai+K. Can you sort the sequence this way? Example Input 2 4 1 1 4 2 3 4 2 1 4 2 3 Example Output yes no