Algorithm

Algorithm/Java

프로그래머스 lv1 - 하샤드 수

https://school.programmers.co.kr/learn/courses/30/lessons/12947 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr - 10으로 나눈 나머지를 활용, 모든 자릿수를 합한 후 그걸로 나눈 나머지가 0인지 판별 class Solution { public boolean solution(int x) { int numbers=0, temp=x; while(temp>0){ numbers+=temp%10; temp/=10; } return (x%numbers==0)?true: false; } }

Algorithm/Java

프로그래머스 lv1 - 정사각형 별찍기

https://school.programmers.co.kr/learn/courses/30/lessons/12969 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr- 이중 반복문 사용class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for(int i=0;i

Algorithm/Java

프로그래머스 lv1 - x만큼 간격이 있는 n개의 숫자

https://school.programmers.co.kr/learn/courses/30/lessons/12954 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr -x의 배수를 x*n까지 출력한다고 생각하면 됨 -반복문 사용 -숫자가 커질 때를 고려해서, x의 데이터타입을 일시적으로 long으로 변환해주기! class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; for(int i=1; i

Algorithm/Java

프로그래머스 lv1 정수 제곱근 판별

https://school.programmers.co.kr/learn/courses/30/lessons/12934 class Solution { public long solution(long n) { long k=(long)Math.sqrt(n); if (n==k*k) return (k+1)*(k+1); else return -1; } }

Algorithm/Python

[백준]1972 놀라운 문자열

https://www.acmicpc.net/problem/1972 import sys def isSurprising(s:str)->bool: ans=True; #surprising n=len(s) for i in range(n-1): #0 ~ n-2쌍 this_set=[]; for j in range(n-i-1):#시작점 temp=s[j]+s[j+i+1] if temp in this_set: return False; else: this_set.append(temp); return ans def surprise(x:str): ans=isSurprising(x) if ans: print(x,"is surprising.") else: print(x,"is NOT surprising."); return line..

Algorithm/Java

프로그래머스 - 비밀지도

https://school.programmers.co.kr/learn/courses/30/lessons/17681 class Solution { void toBinary(int n, int[] numbers, StringBuilder[] real){ for(int i=0;i0){ int temp = t%2; if (temp==1) real[i].setCharAt(fromBackIdx,'#'); t/=2; fromBackIdx--; } } } StringBuilder[] solution(int n, int[] arr1, int[] arr2) { StringBuilder[] answer = new StringBuilder[n]; for(int k=0;k

Algorithm/Java

프로그래머스 - 옹알이(2)

https://school.programmers.co.kr/learn/courses/30/lessons/133499#qna class Solution { public int solution(String[] babbling) { int answer = 0; String[] words = {"aya", "ye", "woo", "ma"}; for(int i=0;i0) { cycle = true; //일치하는 게 없이 한 사이클 다 돌았는지 체크 for (int idx = 0; idx < 4; idx++) { if (babbling[i].startsWith(words[idx])) { cycle = false; babbling[i] = babbling[i].replaceFirst(words[idx], ""); t..

Algorithm/Python

프로그래머스 - 기능개발

https://school.programmers.co.kr/learn/courses/30/lessons/42586# import math def solution(progresses, speeds): answer = [] idx=0 while(idx

Algorithm/Python

프로그래머스 - H - Index

https://school.programmers.co.kr/learn/courses/30/lessons/42747# def solution(citations): h=max(citations) while(h>=0): upper=0 for k in citations: if k>=h : upper+=1 if upper>=h : return h; h-=1; return 0

Algorithm/Python

leetcode - 557. Reverse Words in a String III

https://leetcode.com/problems/reverse-words-in-a-string-iii/submissions/ class Solution: def reverseWords(self, s: str) -> str: list = s.split(" "); ans=list[0][::-1]; for i in range(1,len(list)): ans+=" "+list[i][::-1] return ans

yoursin
'Algorithm' 카테고리의 글 목록 (20 Page)