What's the intention of this problem, why my O(n) code was accepted?

  • 0

    The following o(n) code is short and straightforward and got accepted, but I thought the intention is to use at least binary search?

    int searchInsert(int A[], int n, int target) {
    int index=0;

        while(target>A[index] && index < n)
        return index;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.