Skip to content

Instantly share code, notes, and snippets.

View dktkwhdk1's full-sized avatar
🌻

heeseok kang dktkwhdk1

🌻
View GitHub Profile
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> arr, int divisor) {
vector<int> answer;
sort(arr.begin(), arr.end());
for(int i = 0; i < arr.size(); i++)
#include <string>
#include <vector>
using namespace std;
string solution(string s) {
string answer = "";
int len = s.length();
if(len % 2 != 0) answer += s[len / 2];
else{
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> answers) {
vector<int> answer;
int a[5] = { 1, 2, 3, 4, 5 };
int b[8] = { 2, 1, 2, 3, 2, 4, 2, 5 };
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(string a, string b){
return a + b > b + a;
}
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(string a, string b){
return a + b > b + a;
}
#include <string>
#include <vector>
int answer, result[20];
using namespace std;
// countλ₯Ό result λ°°μ—΄μ˜ 인덱슀둜 μ •ν•˜κ³ , numbers λ°°μ—΄μ˜ μ›μ†Œμ˜ 갯수만큼
// result 배열에 1 λ˜λŠ” 0을 μ±„μ›Œμ„œ 1은 +, 0은 -둜 numbers의 μ›μ†Œλ“€μ„
// μ•Œλ§žκ²Œ κ³„μ‚°ν•˜μ—¬ νƒ€κ²Ÿ λ„˜λ²„μ™€ λΉ„κ΅ν•΄μ£ΌλŠ” ν•¨μˆ˜
void getResult(int count, vector<int> numbers, int target){
#include <string>
#include <vector>
using namespace std;
int solution(int n) {
int cur = n, cnt1 = 0, cnt2 = 0;
while(cur){
int temp = cur % 2;
if(temp) cnt1++; // [1] λ‚˜λ¨Έμ§€κ°€ 0이 μ•„λ‹ˆλΌλ©΄ cnt1을 증가
#include <string>
#include <vector>
using namespace std;
// 두 수λ₯Ό μž…λ ₯λ°›μ•„ μ΅œμ†Œκ³΅λ°°μˆ˜λ₯Ό λ°˜ν™˜ν•˜λŠ” ν•¨μˆ˜
int solution2(int a, int b){
int x = a, y = b;
while(1){
int r = a % b;
#include <string>
#include <vector>
using namespace std;
int solution(int n) {
int answer = 0, sum = 0, prev = 1;
for(int i = 1; i <= n; i++){
// ν˜„μž¬κΉŒμ§€ μ—°μ†λœ μžμ—°μˆ˜μ˜ ν•©κ³Ό λ‹€μŒ μžμ—°μˆ˜λ₯Ό λ”ν•œ 값이
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string solution(string s) {
string answer = "";
string temp = ""; // ν˜„μž¬ 숫자λ₯Ό λ‚˜νƒ€λ‚΄λŠ” string λ³€μˆ˜