Tldr

My approaches seem fine, but it seems that I am unable to code it. This is because I am stuck on the little details behind how to code the algorithm. I watched a video titled “Explained with playing cards” which helped understand the intuition, but its still hard to code.

  • Also, I am not able to explain the reasoning or logic behind the dutch national flag algorithm.

1st attempt: Sort Colors 2023-04-05 14.02.29.excalidraw

Divide and Conquer:

Example with numbers instead of colors:


References

https://leetcode.com/problems/sort-colors/description/

Explained with playing cards