Check if two arrays are cyclic permutations

前端 未结 4 1039
情歌与酒
情歌与酒 2021-02-14 08:41

Given two arrays, how do you check if one is a cyclic permutation of the other?

For example, given a = [1, 2, 3, 1, 5], b = [3, 1, 5, 1, 2], an

4条回答
  •  温柔的废话
    2021-02-14 09:08

    If A and B are cyclic permutations of each other, A will be found in doubled list BB (as will B in AA).

提交回复
热议问题