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.
Yes we can solve it in linear time using a hash table. Load up the vector into the hash table, then for each element, ask if the element (+ or -) k exists in hash table.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
Yes we can solve it in linear time using a hash table. Load up the vector into the hash table, then for each element, ask if the element (+ or -) k exists in hash table.