Tag: dutchnationalflag

  • Sort three colors in an array

    Given an array containing three different colors red ,white and blue denoted by numbers 0,1 and 2 sort the array such that red comes first followed by white followed by blue. Constraints: For example, Given the input: [2,0,1,0,2,1] The output is [0,0,1,1,2,2] Try out the solution here: https://leetcode.com/problems/sort-colors/ Solution: Approach 1 – Count the number…