I implemented these two methods exactly. First one has an extra space of O(n) and the other one is constant space O(1). Runtime of both functions is O(n). This problem is also called Dutch National Flag problem.
We're a place where coders share, stay up-to-date and grow their careers.
I implemented these two methods exactly. First one has an extra space of O(n) and the other one is constant space O(1). Runtime of both functions is O(n). This problem is also called Dutch National Flag problem.