K

@kimjuha19

연속된 1의 최대 길이

Python
6 months ago
arr = [1, 1, 0, 1, 1, 1, 0, 1] max_cnt = 0 cnt = 1 for i in range(len(arr) - 1): if arr[i] == 1 and arr[i + 1] == 1: cnt += 1 else: cnt = 1

연속된 1의 최대 길이

Python
6 months ago
arr = [1, 1, 0, 1, 1, 1, 0, 1] max_cnt = 0 cnt = 1 for i in range(len(arr) - 1): if arr[i] == 1 and arr[i + 1] == 1: cnt += 1 else: cnt = 1

숫자 뒤집기 합

Python
6 months ago
a = 123 rev = int(str(a)[::-1]) answer = a + rev print(answer)

약수 개수 구하기

Python
6 months ago
n = 12 count = 0 for i in range(1, n + 1): if (n % i == 0) : count += 1 print(count) print(sum(1 for i in range(1,n+1) if n % i == 0))

가장 많이 등장한 문자

Python
6 months ago
word = input() result = {} for ch in word: if ch in result: result[ch] += 1 else: result[ch] = 1

연속 증가 여부 판별

Python
6 months ago
arr = [3, 4, 5, 7] ans = "True" for x in range(len(arr)-1): if arr[x+1] == arr[x]+1: ans = "False" break print(ans) print(any(arr[x+1] == arr[x]+1 for x in range(len(arr)-1)))

특정 문자 제거

Python
6 months ago
str = "mississippi" answer = "" for ch in str: if ch != 's': answer += ch print(answer)

숫자 뒤집기

C
6 months ago
#include <stdio.h> int main() { int n = 4521; int sum = 0; int t = 1000; while(n > 0){ sum += n % 10 * t; n /= 10;

가장 많이 나온 수

C
6 months ago
#include <stdio.h> int main() { int arr[10] = {3,5,1,2,6,2,8,1,2,2}; int b[10] = {}; for (int i = 1;i <= 9;i++) { b[arr[i]] += 1; }

가장 많이 나온 수

C
6 months ago
#include <stdio.h> int main() { int arr[] = {3,5,1,2,6,2,8,1,2,2}; int n = sizeof(arr) / sizeof(arr[0]); int counts[100] = {0}; for (int i = 0; i < n; i++) { counts[arr[i]]++; }

숫자 뒤집기

C
6 months ago
#include <stdio.h> int main() { int n = 1204; while (n > 0) { int digit = n % 10; printf("%d", digit); n = n / 10; }

인접한 수의 최대 차이

Python
6 months ago
numbers = [2, 9, 4, 1] max_diff = 0 for i in range(len(numbers) - 1): diff = abs(numbers[i] - numbers[i+1]) if diff > max_diff: max_diff = diff print(max_diff)

약수 개수 구하기

Python
6 months ago
def getMyDivisor(n): divisorsList = [] for i in range(1, n + 1): if (n % i == 0) : divisorsList.append(i) return divisorsList

숫자 뒤집기

Python
6 months ago
n = 320 answer = 0 while n > 0: answer = answer * 10 + (n % 10) n //= 10 print(answer)

최대값 위치 찾기

Python
6 months ago
numbers = [3, 9, 2, 9, 1] print(numbers[-1])

짝수 인덱스 합 구하기

Python
6 months ago
numbers = [4, 7, 1, 9, 3] answer = 0 for i in range(len(numbers)): if i % 2 == 0: answer += numbers[i] print(answer)

주어진 쌍 중에서 가장 큰 최대공약수

Python
6 months ago
import math arr = [[15,20],[36,48],[12,7],[121,44],[39,65]] list = [] answer = 0 a1 = 0 a2 = 0 a3 = 0 a4 = 0

선택한 정수들의 최대 합과 최소 합의 차이를

Python
6 months ago
arr = [3,1,1,4,5,9] arr.sort() M = 3 N = 6 li = 0 big = 0 answer = 0 for i in range(M): li += arr[i]

소스개발 시식단에게 평가

Python
6 months ago
from collections import Counter arr = [1,2,3,4,4,5,6,7,7,8,9,9,9,9,10] count_result = Counter(arr) most_common_item = count_result.most_common(1) value = most_common_item[0][0]

M의 배수인 원소의 합

Python
6 months ago
arr = [4, 2, 1, 3, 9, 5, 6] M = 3 arr.sort() answer = 0 for i in range(len(arr)): if i % 3 ==0 and i!=0: answer += arr[i] print(answer)