Minimum Number of Swaps to Make the String Balanced | Leetcode 1963

  Рет қаралды 2,749

Techdose

Techdose

Күн бұрын

This video explains the Minimum Number of Swaps to Make the String Balanced problem from leetcode 1963. We need to count the imbalance pairs and find the minimum number of swaps needed to make the parenthesis valid. We will solve by stack method as well as with counting closing bracket imbalance optimal approach.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
🟣 JOIN our 𝐋𝐈𝐕𝐄 𝐢𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐭𝐫𝐚𝐢𝐧𝐢𝐧𝐠 𝐩𝐫𝐨𝐠𝐫𝐚𝐦 through whatsapp query: +91 8918633037
🟣 𝐂𝐡𝐞𝐜𝐤𝐨𝐮𝐭 𝐚𝐥𝐥 𝐨𝐮𝐫 𝐂𝐨𝐮𝐫𝐬𝐞𝐬: techdose.co.in/
🔵 LinkedIn: / surya-pratap-kahar
🔴 INSTAGRAM: / techdose_official
🟢 𝐓𝐞𝐜𝐡𝐝𝐨𝐬𝐞-𝟏𝟎𝟎 𝐬𝐡𝐞𝐞𝐭: docs.google.co...
---------------------------------------------------------------------------------------------------------------------------------------------------------------
𝐂𝐎𝐃𝐄 𝐋𝐈𝐍𝐊: gist.github.co...

Пікірлер: 12
@vamshikrishnak6690
@vamshikrishnak6690 Ай бұрын
Found this account and loved it
@techdose4u
@techdose4u Ай бұрын
great :)
@sailendrachettri8521
@sailendrachettri8521 Ай бұрын
Day 8 Completed :)
@techdose4u
@techdose4u Ай бұрын
nice :)
@UNKNOWN-qm6vc
@UNKNOWN-qm6vc Ай бұрын
why we are doing [imbalance + 1/2] why we are adding +1??
@techdose4u
@techdose4u Ай бұрын
to take ceil function.
@karthikk7136
@karthikk7136 Ай бұрын
Sir, what notes app you're using?
@Prakash-jh7hp
@Prakash-jh7hp Ай бұрын
is that optimal solution correct , i did not get the correct answer . private static int optimal(String s){ int closing=0; int maxclosing=0; for(char c : s.toCharArray()){ if(c=='['){ closing--; } else{ closing++; } maxclosing=Math.max(maxclosing, closing); } return (maxclosing+1)/2; } im getting 1 as output for the input "[ ]" but we should get 0 . did i made something wrong?
@WebDevAnjali
@WebDevAnjali Ай бұрын
it IS resulting 0 as an output try clearing cache reset the code n submit
@techdose4u
@techdose4u Ай бұрын
try flushing memory
@АндрейОдинцов-г3у
@АндрейОдинцов-г3у Ай бұрын
гений
@techdose4u
@techdose4u Ай бұрын
Спасибо
Valid Arrangement of Pairs | Leetcode 2097
30:26
Techdose
Рет қаралды 2,6 М.
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,7 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 7 МЛН
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 38 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 592 М.
I Didn’t Believe that AI is the Future of Coding. I Was Right.
6:55
Sabine Hossenfelder
Рет қаралды 594 М.
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,9 МЛН
you will never ask about pointers again after watching this video
8:03
Take K of Each Character From Left and Right | Leetcode 2516
22:38
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 154 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 256 М.