알고리즘 관련 함수 2 + 코테 Tip
·
알고리즘(코딩테스트)
1. 최대값 & 최소값 탐색주어진 컨테이너(주로 벡터나 string)에서 최대 혹은 최소를 구해주는 함수algorithm 헤더 include 필요min_element와 max_element 모두 리턴값은 해당 위치를 가리키는 iterator이다.string에서도 사용할 수 있다!숫자가 문자보다 우선순위가 빠르고, 대문자가 소문자보다 우선순위가 빠르다. (숫자 -> 대문자 -> 소문자)#include #include #include using namespace std;int main(){ vector vec = { 5,4,1,2,10 }; vector::iterator min_it = min_element(vec.begin(), vec.end()); cout ::iterator max_it = max_el..