Advertisement
Guest User

Interview

a guest
Mar 31st, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. There is a book with N pages (indexed from 1 to N). Each page has a certain number of words.
  2. Now play a game with a player machine. Every time you send a message to it, the message contains the information "the sum of words in pages from i to j (1 <= i <= j <= N) is odd or even". The player can save this information and check whether the coming message has conflict with the information from ALL the previous messages. If so, return false and the game ends. If there is no conflict, save this information and return true.
  3.  
  4. Example:
  5. Game one:
  6. [3, 5, odd] -> true
  7. [6, 8, even] -> true
  8. [3, 8, even] -> false
  9. Game Two:
  10. [2, 10, odd] -> true
  11. [8, 14, even] -> true
  12. [2, 14, even] -> true
  13. [8, 10, even] -> false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement