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.
you can use a standard hashtable, where the key is an integer (M - array[i]) and the value is the integer index i. then as you go through the array, you check if (array[current_index]) is in the table; if it is, then the value in that slot is the index i for which M - array[i] = array[current_index] and that is the solution.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
you can use a standard hashtable, where the key is an integer (M - array[i]) and the value is the integer index i. then as you go through the array, you check if (array[current_index]) is in the table; if it is, then the value in that slot is the index i for which M - array[i] = array[current_index] and that is the solution.