본문 바로가기

Problem Solving

(152)
방번호 #include using namespace std; int main() { string N; cin >> N; int maxi = 0; vector arr(10); for(int i = 0; i
구명보트 #include using namespace std; int solution(vector people, int limit) { int answer = 0, index = 0; sort(people.begin(), people.end()); int size = people.size(); while(!people.empty() && index
[백준/C++] 2475번 검증수 #include using namespace std; int main() { int arr[5]; int answer = 0; for(int i = 0; i > arr[i]; answer += pow(arr[i], 2); } cout
Summary Ranges class Solution { public: vector summaryRanges(vector& nums) { vector vec; for (int i = 0, n = nums.size(); i
Single Number class Solution { public: int singleNumber(vector& nums) { int answer = nums[0]; for(int i = 1; i
Count Primes class Solution { public: int countPrimes(int n) { bool arr[5000001]; fill_n(arr, 5000001, 1); int count = 0; for(int i = 2; i
실패율 #include using namespace std; bool compare(pair &a, pair &b) { if(a.first == b.first) return a.second b.first; } vector solution(int N, vector stages) { sort(stages.begin(), stages.end(), greater()); int count_top, count_bottom; double p = 0; vector arr; vector answer; for(int i = 1; i = 0; j--) { if(stages[j] == i) count_top++; if(stages[j] >= i) count_bottom++; } count_bottom != 0 ? p = (doubl..
문자열 다루기 기본 #include #include #include using namespace std; bool solution(string s) { int a = 0; if(s.length() == 4 || s.length() == 6) { for(int i = 0; i 0) break; if(isdigit(s[i]) == false) { ++a; } } return a == 0 ? true : false; }else return false; }