Company: MyKaarma
Difficulty: medium
# Card Stack Rotation With Exactly K Cuts A stack of `N` cards is represented from top to bottom by an array. In one cut, choose a position strictly between two adjacent cards, remove the nonempty prefix above the cut, and place that prefix at the bottom without changing the relative order of any cards. Given the initial stack `A`, the target stack `B`, and an integer `K`, determine whether `A` can become `B` after exactly `K` cuts. ## Input Format - The first line contains `N` and `K`. - The second line contains `N` space-separated integers describing `A` from top to bottom. - The third line contains `N` space-separated integers describing `B` from top to bottom. ## Output Format Print `YES` if the transformation is possible after exactly `K` cuts; otherwise print `NO`. ## Constraints - `1 <= N <= 500000` - `0 <= K <= 1000000000` - `-1000000000 <= A[i], B[i] <= 1000000000` ## Example 1 Input: 4 1 1 2 3 4 3 4 1 2 Output: YES ## Example 2 Input: 2 2 10 20 10 20 Output: