We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
https://pastebin.com/51RRGvGL
Do check my code for any doubts regarding this question simply using a trie solved this question. Just maintain a vector at every node whose number indexes are on the way and check whether to take such path there exists a number in range l to r using a lower_bound if there continue such maximum path or else the other.
{all those indexes of numbers will be sorted because of the increasing way of adding these numbers to trie}
Max Space and time:O(16*N)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
XOR key
You are viewing a single comment's thread. Return to all comments →
https://pastebin.com/51RRGvGL Do check my code for any doubts regarding this question simply using a trie solved this question. Just maintain a vector at every node whose number indexes are on the way and check whether to take such path there exists a number in range l to r using a lower_bound if there continue such maximum path or else the other. {all those indexes of numbers will be sorted because of the increasing way of adding these numbers to trie} Max Space and time:O(16*N)