p23_5
Idea -> For a mismatch,(A=s[i],b=t[j]) find first b in s ahead of index i. Now if in between i to index where index in next place in s where b occurs, the min v
Idea -> For a mismatch,(A=s[i],b=t[j]) find first b in s ahead of index i. Now if in between i to index where index in next place in s where b occurs, the min value is < b, then wiggle(buuble sort shift) not possible. Else it is possible\nImplementation trick-> Bubbling index element to i by shifting everything is costly, so instead just put a # value at s[index] and whenever i points to # skip it\nSo basically comparison moves from (i,j) -> (i,j+1)\nBrute force idea\nA=s[i]\nB=t[j]\nif(A==B) i++and j++\nif(A<B) then return false not possible at all\nelse\nFind the next index of B in s, say it is index\nNow wiggle(like bubble sort) bring s[index] to i, by shifting each ele to right\nNow dont actually shift the elements just put s[inde]=somerandomvalue\nand continue on this random value\nFind the min value from i to index in s\nif(min != B) return false;\nelse proceed j++\nUse seg tree for finding the range query instaed
[]