标签:container pos write class return containe alt sea div
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public class Solution { /** * @param nums: An integer array sorted in ascending order * @param target: An integer * @return an integer */ public int findPosition(int[] nums, int target) { // Write your code here if(nums == null || nums.length == 0)return -1; int left = 0, right = nums.length - 1; while(left < right){ int mid = left + (right - left) / 2; if(nums[mid] < target) left = mid + 1; else right = mid; } if(nums[right] == target) return right; return -1; }} |
标签:container pos write class return containe alt sea div
原文地址:http://www.cnblogs.com/zhxshseu/p/b40a2a8739a00d055d248b35db5a0cb8.html