Блог пользователя NewCoder100

Автор NewCoder100, история, 7 месяцев назад, По-английски

Can someone please tell me an approach and possibly the optimal code for this problem.

Given an array A, you need to split the array into non empty subarrays such that each subarray is a permutation (each number from 1 to the n appears exactly once where n is the size of the subarray). For eg: A=2,1,3,6,3,1,2,5,4,2,1. Then the subarrays are {2,1,3},{6,3,1,2,5,4},{2,1}. You need to return these subarrays. It is guaranteed that answer always exists and the given array can always be split in such a way that every subarray is a permutation.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится