Тёмный

75. Sort Colors | partition sorting | leetcode daily challenge | DSA | Hindi 

shashCode
Подписаться 14 тыс.
Просмотров 1,6 тыс.
50% 1

Problem Name:
75. Sort Colors
Problem Statement:
Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.
We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.
You must solve this problem without using the library's sort function.
Problem link:
leetcode.com/problems/sort-co...
Java Plus DSA Placement Course Playlist:
• Java and DSA Course Pl...
Java Plus DSA Sheet:
docs.google.com/spreadsheets/...
Notes:
github.com/Tiwarishashwat/Jav...
Telegram Link:
shashwattiwari.page.link/tele...
Ultimate Recursion Series Playlist:
• Recursion and Backtrac...
Instagram Handle: (@shashwat_tiwari_st)
shashwattiwari.page.link/shas...
Samsung Interview Experience:
• I cracked Samsung | SR...
Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
Timestamp:
0:00 - Introduction
#ShashwatTiwari #coding​​ #problemsolving​

Опубликовано:

 

10 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 20   
@priyanshkumariitd
@priyanshkumariitd 29 дней назад
Thank you bhaiya !! 3 pointer approach !! new concept to sort in O(N)
@RohitKumar-dz8dh
@RohitKumar-dz8dh 29 дней назад
Thanks 😊
@user-oi5ls4rs5g
@user-oi5ls4rs5g 28 дней назад
sir tree series k baad ...new lecture kb tak ayenge plz reply
@PiyushSharma-we8yd
@PiyushSharma-we8yd 29 дней назад
first view bhaiya. Thanks for uploading, 13K soooooonnn!!!!!
@karanchauke
@karanchauke 29 дней назад
I think Flipkart Company 😂😂 Bhaiya
@DevanshGupta-io7rl
@DevanshGupta-io7rl 27 дней назад
sort stl laga k solve kr diya kya samaj muje accept krega ??
@anandkumarnitrourkela7404
@anandkumarnitrourkela7404 29 дней назад
Bhaiya preparing for placements. struggling with graphs and dp what to do? Please guide
@8daudio672
@8daudio672 28 дней назад
Strike bhai op
@anushkaap
@anushkaap 29 дней назад
Hello Sir, how is this approach i wrote on myself?? class Solution { public void sortColors(int[] nums) { int w = 0, r = 0, b = 0; for(int num: nums) { if(num == 0) r++; else if(num == 1) w++; else b++; } int i = 0; while(r > 0) { nums[i] = 0; r--; i++; } while(w > 0) { nums[i] = 1; w--; i++; } while(b > 0) { nums[i] = 2; b--; i++; } } }
@shashwat_tiwari_st
@shashwat_tiwari_st 29 дней назад
Good work 👏 you used counting sort without extra space. This solution meets all requirement, but it is not single pass solution, so it's not the most optimal one. TC will be same. But Looping is done multiple times.
@anushkaap
@anushkaap 29 дней назад
@@shashwat_tiwari_st Thanks sir, I'll keep it in mind.
@DanishAli-ip2sj
@DanishAli-ip2sj 29 дней назад
Waise ye qn medium lebel ka ni lga
@Mrsainiworld
@Mrsainiworld 28 дней назад
I think Twitter😅😅😅😅
@pushanmukhopadhyay3379
@pushanmukhopadhyay3379 29 дней назад
Dutch flag algo
@shashwat_tiwari_st
@shashwat_tiwari_st 28 дней назад
Yes!
@dibbodas4116
@dibbodas4116 29 дней назад
sir how is the approach? class Solution { public: void sortColors(vector& nums) { int z = 0, o = 0, t = 0; for(int i=0;i0) { nums[i] = 1; o--; } else { nums[i] = 2; t--; } } } };
@shashwat_tiwari_st
@shashwat_tiwari_st 28 дней назад
Badhiya hai. Counting sort without space, but multiple passes hai. Solution acha hai but most optimal nhi hai because of multiple loops (passes.) But good logic 👏💯
@dibbodas4116
@dibbodas4116 28 дней назад
@@shashwat_tiwari_st yes bhaiya apka solution dekhne thora dikkat hua samajne me
@robinofautumn99
@robinofautumn99 28 дней назад
long live yahoo🤣🤣
Далее
Телеграмм-Колян Карелия
00:14
Просмотров 184 тыс.
Zlatan embarrasses Speed 😂 #ishowspeed
00:32
Просмотров 8 млн
Зачем нужны указатели в C++?
8:14
Просмотров 3,2 тыс.
Sort colors | Leetcode #75
6:02
Просмотров 84 тыс.
8 patterns to solve 80% Leetcode problems
7:30
Просмотров 233 тыс.
Learn Quick Sort in 13 minutes ⚡
13:49
Просмотров 300 тыс.