<reponame>vishrutkmr7/DailyPracticeProblemsDIP
#  This problem was recently asked by Facebook:

# Given an array and an integer k, rotate the array by k spaces. Do this without generating a new array and without using extra space.


def rotate_list(nums, k):
    # Fill this in.
    n = len(nums)
    for i in range(0, k):
        a.append(a[0])
        a.pop(0)


a = [1, 2, 3, 4, 5]
rotate_list(a, 2)
print(a)
# [3, 4, 5, 1, 2]

#  This problem was recently asked by Facebook:

# Given an array and an integer k, rotate the array by k spaces. Do this without generating a new array and without using extra space.


def rotate_list(nums, k):
    # Fill this in.
    n = len(nums)
    for i in range(0, k):
        a.append(a[0])
        a.pop(0)


a = [1, 2, 3, 4, 5]
rotate_list(a, 2)
print(a)
# [3, 4, 5, 1, 2]
#  This problem was recently asked by Facebook: # Given an array and an integer k, rotate the array by k spaces. Do this without generating a new array and without using extra space. # Fill this in. # [3, 4, 5, 1, 2]