- list< int > myList = { 2, 6, 12, 13, 15, 18, 20};
cout << binary_search(myList.begin(), myList.end(), 20) ;
Why is its output 1 and time complexity linear? I think it should be 20 and logarithmic.
- vector< int > data = {100, 142, 138, 96, 32, 149};
swap(data[2], data[5]);
int val1 = *max_element(data.begin(), data.begin() +3);
int val2 = *max_element(data.begin()+3,data.end());
cout<< min(val1, val2);
Why is output 138 and not 142?
- string s = “bca”;
do {
cout << s << ' ';
}
while(next_permutation(s.begin(), s.end()));
cout << s;
What is the output of the given code? I think it should be never ending loop.