Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

sort colors

class Solution {
public:
    void sortColors(vector<int>& nums) {
        int lo = 0; 
        int hi = nums.size() - 1; 
        int mid = 0; 

        while (mid <= hi) { 
            switch (nums[mid]) { 

            // If the element is 0 
            case 0: 
                swap(nums[lo++], nums[mid++]); 
                break; 

            // If the element is 1 . 
            case 1: 
                mid++; 
                break; 

            // If the element is 2 
            case 2: 
                swap(nums[mid], nums[hi--]); 
                break; 
            }
        }
         
    }
};
Comment

PREVIOUS NEXT
Code Example
Java :: set integer array value to null java 
Java :: setlist arraylist java swing example 
Java :: mergesort parallelization using spark 
Java :: number guessing game in java using oops 
Java :: konva crop outside width and height of image 
Java :: spring data rest id missing 
Java :: android bootom app bar tab bar 
Java :: android int color = ContextCompat.getColor(getContext(), mColorResourceId); 
Java :: java reverse a word 
Java :: java.lang.String cannot be cast to java.util.Map 
Java :: Java Enable assertion in package names 
Java :: extended window style values in java 
Java :: System.Windows.Interactivity 
Java :: how to set to nothing a ComboBox in java 
Java :: java spring crudrepository generate insert instead of update 
Java :: Magic square java user input 
Java :: capitalize a letter in java 
Java :: difido 
Java :: a Java-8 stream of batches, 
Java :: dynamic fib 
Java :: java calculator joptionpane 
Java :: android studio viewpager 
Java :: comvertir a java 
Java :: dividing numbers using method 
Java :: program to calculate and return the sum of distance between the adjacent numbers in an array of positive integer java 
Java :: Quartz spring maven driver 
Java :: add words from string to collection java 
Java :: java set custom property cmd 
Java :: Java Public Access Modifier package one 
Java :: modelmapper abstract class 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =