#include #include #include #include using namespace std; int binarySearch(std::vector arr, int numToSearchFor) { std::sort(arr.begin(), arr.end()); int first = 0; int last = arr.size() - 1; int position = INT_MIN; int middle = INT_MIN; bool found = false; while (!found && first <= last) { middle = (first + last) / 2; if (arr[middle] == numToSearchFor) { found = true; position = middle; } else if (arr[middle] > numToSearchFor) { last = middle - 1; } else { first = middle + 1; } } return position; } std::tuple binarySearch(std::vector> arr, int numToSearchFor) { for (int i = 0; i < arr.size(); ++i) { int columnLocation = binarySearch(arr[i], numToSearchFor); if (columnLocation != INT_MIN) { return {i, columnLocation}; } } return {INT_MIN, INT_MIN}; }