public int[] searchRange_iter(int[] A, int target) {
        // Start typing your Java solution below
        // DO NOT write main() function
        int[] res = new int[2];
        res[0] = -1;
        res[1] = -1;
        if (A == null || A.length == 0) return res;

        int l = 0, h = A.length - 1;
        while (l <= h) {
            int mid = (l+h)/2;
            if (A[mid] == target) {
                res[0] = mid;
                h = mid - 1;
            } else if (A[mid] > target) h = mid - 1;
            else l = mid + 1;
        }
        l = 0;
        h = A.length - 1;
        while (l <= h) {
            int mid = (l+h)/2;
            if (A[mid] == target) {
                res[1] = mid;
                l = mid + 1;
            } else if (A[mid] < target) l = mid + 1;
            else h = mid - 1;
        }

        return res;
    }