You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// You are given a string s, which contains stars *.
6
+
// In one operation, you can:
7
+
// Choose a star in s.
8
+
// Remove the closest non-star character to its left, as well as remove the star itself.
9
+
// Return the string after all stars have been removed.
10
+
11
+
// Note:
12
+
// The input will be generated such that the operation is always possible.
13
+
// It can be shown that the resulting string will always be unique.
14
+
15
+
// Understand the problem first...
16
+
17
+
// hme aik string `s` ke name se dia gia hy hum ne is string me se star ko remove krna hy aur str ke left pe jo letter hy us ko bi remove krna hy aur then string return kr dena hy agr koi bi nahi milta tu pir empty string return kr dena hy.
18
+
19
+
// Solution
20
+
21
+
// is problem ko hal krne ke liye hum log stack data structire ka use kre ge. sb se pehle hum aik stack initialize kre ge then us string per loop lga ke hr hr letter ko nikal le ge then hum ye dekhe ke agr ane wala character * se match krta hy tu us se left wale ko remove kr do warna append kr do. aik baat yaad rakhe ke hum comapre tb hi kr paye ge jb stack me kuch ho ga. Then is stack ko string me return kr de ge.
0 commit comments