euisblue
12903. 가운데 글자 가져오기

Level 1 가운데 글자 가져오기

시간 복잡도: O(1)

1#include <string> 2#include <vector> 3using namespace std; 4 5string solution(string s) { 6 int mid = s.size() >> 1; 7 string str = ""; 8 9 if((s.size()&1) == 0) { 10 str += s[mid-1]; 11 str += s[mid]; 12 } 13 else str = s[mid]; 14 15 return str; 16}