Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. list{1,4,7,6}
  2.  
  3. getNearestTop(int input){
  4. return list.OrderBy(i => i)
  5. .First();
  6.  
  7. }
  8.  
  9. getNearestBottom(int input){
  10. return list.OrderBy(i => i)
  11. .Last();
  12. }
  13.  
  14. getNearestBottom(5) should return 4
  15. getNearestTop(5) should return 6
  16. getNearestBottom(4) should return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement