Day 318:Maximum Twin Sum of a Linked List
Find the middle node,reverse the second half of the list and iteratively add up pairs of first half and reversed second half to find maxSum.For zero elements,we have no maxSum and for a element,the head is its maxSum
The irony is people are okay to wake up at night to watch matches but has anyone tried the same with Tahajjud? Ik it’s not a fard ibadah but if you can wake up for matches pray tahajjud also rewards fun.
Day 316:Number of ways to assign edge weights 2
Use of binary lifting to find the lowest common ancestor between two nodes in log time,use of dfs to calculate depth from root node to any other node,combining these to find edges and use of fastPow to calculate 2^k-1,where k=edges
Day 314:Maximum total Subarray Value 2
Segment trees for querying,value of a bigger window does not exceed the smaller window,use of max heap to pick the top k value subarrays,bfs traversal while picking subarray windows,learned new stuffs,still got to work more :)