algorithm

algorithm

[프로그래머스] 약수의 개수와 덧셈

class Solution { public int solution(int left, int right) { int answer = 0; int cnt = 0; // 약수의 갯수를 파악하기 위한 변수 for (int i = left; i

algorithm

[프로그래머스] Lv 1 신규 아이디 추천

class Solution { public String solution(String new_id) { // 1단계 String step2 = ""; step2 = new_id.toLowerCase(); // 모든 문자 소문자로 치환 // 2단계 String step3 = step2.replaceAll("[^a-z0-9_.-]", ""); // 정규식을 통한 조건에 맞는 문자제외하고 모두 제거 // 3단계 // a부터z까지, 0부터9까지 _.-제외하고 전부 제거 (replaceAll 함수사용) String step4 = ""; step4 = step3.replaceAll("[.]+", "."); // 마침표(.)가 2번이상 연속될시 마침표(.) 1개로 치환 // 4단계 String step5 = ""; S..

algorithm

[프로그래머스] Lv 1 소수 만들기

이 문제는 3개의 수를 더했을때 소수를 어떻게 처리할까 고민을 하다가 정답 문제를 보고 이해를 한 케이스였다. 소수에 대한 개념은 알겠는데 어떻게 구현해야할까 고민을 많이 했는데 다른 사람의 정답을 보니 너무 어렵게만 생각하는거보다 단순하게 생각하는 것이 좋겠다 라는 생각이 들었다. 위 사진과 같은 3중 for문을 돌리게 되면은 위 사진과 같은 반복순서를 가지게 되고 총 4회를 반복하게 된다. i j k 를 모두 더한 값을 최대값으로 잡고 다시 반복문을 돌리게 되면 1과 자신의 값만이 나누어지므로 cnt값을 올리고 cnt값이 2인 경우만 소수의 경우로 판단하고 answer 값을 +해준다. 3중 for문을 쓴다는건 굉장한 시간복잡도를 발생시키기 때문에 추후에 이 3중 for문을 쓰기에는 어려울수도 있으나 ..

algorithm

[프로그래머스] Lv 1 시저 암호

자세한 정보 클릭 GitHub - leemeo3/algorithm: This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.c This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - GitHub - leemeo3/algorithm: This is a auto push repository for Bae... github.com 순수하게 아스키코드에 +n만큼만 하면 되는 문제라고 생각했는데 n의 범위가 최대 25..

algorithm

[프로그래머스] Lv 1 문자열 내림차순으로 배치하기

자세한 정보 클릭 GitHub - leemeo3/algorithm: This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.c This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - GitHub - leemeo3/algorithm: This is a auto push repository for Bae... github.com 이 문제는 아스키코드에 대한 이해가 있었다면 쉽게 접근할 수 있는 문제였다. 이 문제..

algorithm

[프로그래머스] Lv 1 최소 직사각형

자세한 정보 클릭 GitHub - leemeo3/algorithm: This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.c This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - GitHub - leemeo3/algorithm: This is a auto push repository for Bae... github.com

algorithm

[프로그래머스] Lv 1 두개 뽑아서 더하기

자세한 정보 클릭 GitHub - leemeo3/algorithm: This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.c This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - GitHub - leemeo3/algorithm: This is a auto push repository for Bae... github.com set 함수를 처음 써봤는데 중복을 제거하는 부분에 있어서는 굉장히 유용한 함수라고 ..

algorithm

[프로그래머스] Lv 1 완주하지 못한 선수

자세한 설명 클릭 GitHub - leemeo3/algorithm: This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.c This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - GitHub - leemeo3/algorithm: This is a auto push repository for Bae... github.com

3hoon
'algorithm' 카테고리의 글 목록