You can use the "find()" function to find if a value exists inside of a vector as such:
(find(vector.begin(), vector.end(), alueToBeFound) != vector.end());
My question is, how do you perform this search in a two-dimensional vector but only on one of the dimensions?
For instance, if I had "vector< vector
To solve for only 1 of the variables do a for loop. for(int k = 0; k < i; k++) { //do something vector[k][j] or change k's to i's. }
This is what I ended up doing (already finished). However, after spending 5 hours finally getting all of my extremely inefficient code (so many loops..) to work, I realized I could have just created a class structure and been done in 20 minutes. FML.
Join our real-time social learning platform and learn together with your friends!