Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

class Solution { public: int firstMissingPositive(int A[], int n) { if (n == 0) return 1; sort(A, A + n); for (int i = 1; ;i++) { int *p = find(A, A + n, i); if (p == A + n) return i; } } };

The time complexity will be higher than O(n), though this code might be accepted by the OJ.

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