Accepted! really?


  • -1
    D

    It has been accepted. But it could be better.

    class Solution {
    public:
        int search(int A[], int n, int target) {
            
            for (int i = 0; i < n; i++)
            {
                if (A[i] == target)
                {
                    return i;
                }
            }
            return -1;
            
        }
    };

  • 0

    It is clear that this is not the optimal solution even it was accepted.


  • 0
    N

    Whether you can reduce the time complexity under O(n) or not is the purpose of this question.


Log in to reply
 

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