Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. using System.Collections.Generic;
  2.  
  3. namespace Autocomplete
  4. {
  5. public class RightBorderTask
  6. {
  7. public static int GetRightBorderIndex(IReadOnlyList<string> phrases, string prefix,int left,int right)
  8. {
  9. while (left < right - 1)
  10. {
  11. var mid = (left + right + 1) / 2;
  12. if (string.Compare(phrases[mid], prefix) <= 0 || phrases[mid].StartsWith(prefix))
  13. left = mid;
  14. else
  15. right = mid;
  16. }
  17. return right;
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement