Skip to content

Instantly share code, notes, and snippets.

@mhshams
Last active January 22, 2016 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhshams/b700aae4987da20fd125 to your computer and use it in GitHub Desktop.
Save mhshams/b700aae4987da20fd125 to your computer and use it in GitHub Desktop.
/**
* A function that takes TWO arrays of Integer, compares them and then returns:
* - 1, if the first array is greater than second one
* - -1, if the second array is greater tan first one
* - 0, if both arrays are the same.
*
* How to Compare?
* Starting from index 0, compare the elements of both array in the same positions until you find one is bigger than the other.
*
* Examples:
* - [1, 2, 3] is bigger than [1, 2, 0] then: return 1
* - [3, 1] is smallaer than [4] then: return -1
* - [2] is bigger than [1, 2, 3, 4, 16] then: return 1
* - [3, 2, 5] is smaller than [3, 2, 5, 0] then: return -1
* - [3, 1, 5] is equal to [3, 1, 5] then: return 0
*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment