Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- namespace Autocomplete
- {
- public class RightBorderTask
- {
- public static int GetRightBorderIndex(IReadOnlyList<string> phrases, string prefix,int left,int right)
- {
- while (left < right - 1)
- {
- var mid = (left + right + 1) / 2;
- if (string.Compare(phrases[mid], prefix) <= 0 || phrases[mid].StartsWith(prefix))
- left = mid;
- else
- right = mid;
- }
- return right;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement