Ero-Sennin's blog

By Ero-Sennin, history, 19 months ago, In English

Given a rooted tree with N weighted nodes. Find the maximum bitwise xor of two non-overlapping subtree sums in a tree. Subtree sum of a node is the sum of weights of all nodes present in its subtree including the node itself.

This problem is similar to finding maximum xor of two numbers in an array but I am not able to understand how to include non-overlapping condition. Could you help how to approach this problem and if you can provide code it would be very helpful as well.

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By Ero-Sennin, history, 22 months ago, In English

Given an array a, find the number of pairs such that a[i]<=a[j]+k where i<j? Constraints — size of array <=1e5 I tried to use the concept of merge sort the way we use it to count inversions in an unsorted array, but I am getting WA. Could you help how to approach this problem and if you can provide code it would be very helpful.

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it