Skip to content

Instantly share code, notes, and snippets.

@tjkemper
Last active May 9, 2017 21:06
Show Gist options
  • Save tjkemper/ce0c0f12c5b343bba40366033149fa59 to your computer and use it in GitHub Desktop.
Save tjkemper/ce0c0f12c5b343bba40366033149fa59 to your computer and use it in GitHub Desktop.

Left Rotate

Write a method leftRotate which rotates the array n times. Each rotation shifts all elements to the left and places the first element at the end.

leftRotate(int[] array, int n)
  //write pseudocode

Case 1:

array = [1,2,3,4,5]
n = 1
result = [2,3,4,5,1]

Case 2:

array = [1,2,3,4,5]
n = 3
result = ?

Case 3:

array = [1,2,3,4,5]
n = 5
result = ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment