package com.fishercoder.solutions;

import java.util.stream.IntStream;

/**
 * 1055. Fixed Point
 *
 * Given an array A of distinct integers sorted in ascending order,
 * return the smallest index i that satisfies A[i] == i.  Return -1 if no such i exists.
 *
 * Example 1:
 * Input: [-10,-5,0,3,7]
 * Output: 3
 * Explanation:
 * For the given array, A[0] = -10, A[1] = -5, A[2] = 0, A[3] = 3, thus the output is 3.
 *
 * Example 2:
 * Input: [0,2,5,8,17]
 * Output: 0
 * Explanation:
 * A[0] = 0, thus the output is 0.
 *
 * Example 3:
 * Input: [-10,-5,3,4,7,9]
 * Output: -1
 * Explanation:
 * There is no such i that A[i] = i, thus the output is -1.
 *
 * Note:
 *
 * 1 <= A.length < 10^4
 * -10^9 <= A[i] <= 10^9
 * */
public class _1055 {
    public static class Solution1 {
        public int fixedPoint(int[] A) {
            return IntStream.range(0, A.length).filter(i -> A[i] == i).findFirst().orElse(-1);
        }
    }
}

@@ -69,661 +69,8 @@
 m;%0A%0A
-/**%0A * 1055. Fixed Point%0A *%0A * Given an array A of distinct integers sorted in ascending order,%0A * return the smallest index i that satisfies A%5Bi%5D == i.  Return -1 if no such i exists.%0A *%0A * Example 1:%0A * Input: %5B-10,-5,0,3,7%5D%0A * Output: 3%0A * Explanation:%0A * For the given array, A%5B0%5D = -10, A%5B1%5D = -5, A%5B2%5D = 0, A%5B3%5D = 3, thus the output is 3.%0A *%0A * Example 2:%0A * Input: %5B0,2,5,8,17%5D%0A * Output: 0%0A * Explanation:%0A * A%5B0%5D = 0, thus the output is 0.%0A *%0A * Example 3:%0A * Input: %5B-10,-5,3,4,7,9%5D%0A * Output: -1%0A * Explanation:%0A * There is no such i that A%5Bi%5D = i, thus the output is -1.%0A *%0A * Note:%0A *%0A * 1 %3C= A.length %3C 10%5E4%0A * -10%5E9 %3C= A%5Bi%5D %3C= 10%5E9%0A * */%0A
 publ

refactor 1055