프로그래머스 - JAVA/Level 1
[JAVA] 프로그래머스 Lv.1 : 나머지가 1이 되는 수 찾기
새우버거♬
2022. 5. 21. 15:41
🔥 월간 코드 챌린지 시즌3
예제:
arr | result |
[1,1,3,3,0,1,1] | [1,3,0,1] |
[4,4,4,3,3] | [4,3] |
제한 조건:
- 3 ≤ n ≤ 1,000,000
Solution #1
class Solution {
public int solution(int n) {
for(int i = 2; i < n; i++){
if(n % i == 1) return i;
}
return 1;
}
}
More Algorithm!
👇👇
github.com/ggujangi/ggu.programmers
ggujangi/ggu.programmers
프로그래머스 알고리즘, JAVA. Contribute to ggujangi/ggu.programmers development by creating an account on GitHub.
github.com
출처 : 프로그래머스