Cut
ABC 368Problem 48 of 50
EasyWhat to do
Given a list of cards and an integer k, move the bottom k cards to the top of the stack. Return the new order as a space-separated string. For example, cards=[1,2,3,4,5], k=3 → '3 4 5 1 2'.
Key Concepts
arrays/lists
slicing
input/output
basic list manipulation
Examples
Input:
n = 5, k = 3, cards = [1, 2, 3, 4, 5]
Output:
3 4 5 1 2
Input:
n = 6, k = 2, cards = [1, 2, 1, 2, 1, 2]
Output:
1 2 1 2 1 2
Tips for Beginners
- Focus on understanding the logic, not memorizing syntax
- Use print statements to debug your code
- Don't worry about input parsing - the function handles that for you
- If stuck, try writing out your solution on paper first
Python Editor
Loading Python...