LeetCode #75: Sort 0s,1s, 2s (Sort Colors) | Array Easy Level | Asked in Top Companies | DSA Series

Поділитися
Вставка
  • Опубліковано 29 січ 2025

КОМЕНТАРІ • 1

  • @DTechSchool
    @DTechSchool  10 днів тому +2

    [Java] Efficient Solution for LeetCode #75: Sort Colors | 0ms Runtime
    Asked In: [Paytm, Flipkart, Morgan Stanley, Amazon, Microsoft, OYO Rooms, Samsung, Snapdeal, Hike, MakeMyTrip, Ola Cabs, Walmart, MAQ Software, Adobe, Yatra.com, SAP Labs, Qualcomm]
    Solution:
    1: Brute Force Approach: Time Com: O(NLogN)
    Arrays.sort(nums);
    2: Count Techniques: Time com: O(N) + O(N) ===> O(2N)
    int zerocount =0;
    int onecount = 0;
    int twocount = 0;
    for(int i =0; i