标签:let ext 目标 color 说明 bsp public div gre
class Solution { public char nextGreatestLetter(char[] letters, char target) { //二分查找 if(letters[0] > target) return letters[0]; int len = letters.length; int l = 0,h= len - 1; while(l <= h){ int m = (l + h)/2; if(letters[m] <= target) l = m + 1; else{ h = m -1; } } //找到了 if(l < len){ return letters[l]; } //未找到:说明全部小于等于target return letters[0]; } }
标签:let ext 目标 color 说明 bsp public div gre
原文地址:https://www.cnblogs.com/come-on-pxw/p/12783527.html