Magic of Algorithm header file in C++
In C++ Algorithm header file contains bountiful magical operations which are very important in competitive programming and take less time to write code. There are some predefined methods in the algorithm: 1. find(): This method helps to search an element in a vector or array. It will return the address to that particular index. We can calculate the index by subtracting the base address of the array from it. Syntax: auto it = find(arr,arr+n,key); int index= it-arr; 2. Upper bound and lower bound: upper_bound() return index to ending index of searched element. lower_bound() return first index of searched element. 3. reverse(): used to reverse a string 4. swap(): used to swap two values variables 5. sort(): sort an array or vector. By specify first address nd end element. Map: begin() – Returns an iterator to the first element in the map end() – Returns an iterator to the theoretical element that follows last e...