Hackerrank | Left Rotate | One line solution in Python

preview_player
Показать описание
In this video lecture, we learn to solve a Hackerrank Problem from Data Structures/Array Section titled "Left Rotate", it is also repeated in LinkedIn Interview section Titled "Left Rotate the Array".
I have solved this problem using Python using two methods.
1. As mentioned in the explaination, removing the first element and adding at the end, repeating this step d number of times.
2. One line solution using List Slicing.

n,d = tuple( map(int, input().split() ) )

a = list ( map(int, input().split()) )

d = d % n

print(*(a[d : ] + a[ : d]))

#hackerranksolutions #hackerrank #python #pythonprogramming #pythoninterviewquestions #datastructures
Рекомендации по теме
visit shbcf.ru