First missing positive integer in linear time and constant space
It would be good to have some comments in the code explaining why (a) it works; (b) it takes linear time.




        int i = 0;
        for (i = 0; i &lt; n; i++) {



I would prefer to use for (int i = 0; ...) and similarly for the other loop over i: they don't need to use the same variable, and keeping scopes as small as possible helps understanding and maintenance. But if you prefer to keep the variable in the wider scope, there's no need to initialise it twice. Either of

        int i = 0;
        for (; i &lt; n; i++) {


or

        int i;
        for (i = 0; i &lt; n; i++) {


works fine.




            if (val &lt;= 0 || val &gt; n)
                continue;
            while (val != arr[val - 1]) {
                int nextval = arr[val - 1];
                arr[val - 1] = val;
                val = nextval;
                if (val &lt;= 0 || val &gt; n) {
                    break;
                }
            }



It's a bit inelegant to apply the range test twice. A simple refactor gives

        while (val &gt; 0 &amp;&amp; val &lt;= n &amp;&amp; val != arr[val - 1]) {
            int nextval = arr[val - 1];
            arr[val - 1] = val;
            val = nextval;
        }





        }
        return n+1;

    }



For consistency I would add whitespace around +. The blank line makes more sense to me before the return rather than after it, and I would also add a blank line separating the two loops.

The fact that I'm nitpicking whitespace like this is a good sign: I haven't found anything which I consider to be a major problem.