Can someone please explain the merge function(line 33 to 49) in below code. Why line 48 and 49 always holds true in all the cases!
i am unable to understand the what values u are storing in this varible
struct Tree{
ll mf; // max frequency
ll mpf; // max prefix frequency
ll msf; // max suffix frequency
ll mpn; // max prefix number
ll msn; // max suffix number
};
I think its clear what hes storing. Where did you get stuck gyan? If you arent familiar with struct, its allows you to make a custom data type.
reason of making this variable and what does the necessity.
merge function in this programme is little compicated in this code.
need help @vijju123. yep i am familiar with struct.
@vijju123 @divik544 Whats the logic behind using left(prefix) and right(suffix) part to find the max frequency in current node?
if u read the problem carefully it is mentioned that the input will be sorted so at any node in a segment tree we store 3 values. Added comments for clarity LINK
Now it became clear… thanks for adding comments in the code