
[프로그래머스] 약수의 개수와 덧셈
class Solution { public int solution(int left, int right) { int answer = 0; int cnt = 0; // 약수의 갯수를 파악하기 위한 변수 for (int i = left; i
class Solution { public int solution(int left, int right) { int answer = 0; int cnt = 0; // 약수의 갯수를 파악하기 위한 변수 for (int i = left; i
2주차 프로그래밍 기초 주차 발제 항해수료까지의 과정중에 가장 어떤 과정일지 느낌이 오지않는 주차였다. 이유는 내가 생각한 알고리즘 문제는 DFS나 BFS 혹은 아래사진의 빨간색 박스안의 내용이였다. 근데 과연 2주차 Pre-Onbording기간까지 합치면 3주인데 과연 3주차만에 저러한 개념들을 이해할 수 있을까? 라는 의문이 계속 들었다. 그래서 이 2주차 과정이 문법을 다지는 기간인지 아니면 정말 알고리즘 개념을 익히는 기간인지 느낌이 오지 않았다. 실상을 파보니 문법과 내가 이해하는 알고리즘의 그 사이의 경계 어느곳이였다. 사실 굉장히 겁먹기도 했었다. 난 사전에 저런 개념에 대해 먼저 접해본적이 있었는데 그때 정말 이해가 안됐다. 정말 수학공식처럼 달달 외워야하는걸까? 라는 고민을 많이 했던거..
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..
이 문제는 3개의 수를 더했을때 소수를 어떻게 처리할까 고민을 하다가 정답 문제를 보고 이해를 한 케이스였다. 소수에 대한 개념은 알겠는데 어떻게 구현해야할까 고민을 많이 했는데 다른 사람의 정답을 보니 너무 어렵게만 생각하는거보다 단순하게 생각하는 것이 좋겠다 라는 생각이 들었다. 위 사진과 같은 3중 for문을 돌리게 되면은 위 사진과 같은 반복순서를 가지게 되고 총 4회를 반복하게 된다. i j k 를 모두 더한 값을 최대값으로 잡고 다시 반복문을 돌리게 되면 1과 자신의 값만이 나누어지므로 cnt값을 올리고 cnt값이 2인 경우만 소수의 경우로 판단하고 answer 값을 +해준다. 3중 for문을 쓴다는건 굉장한 시간복잡도를 발생시키기 때문에 추후에 이 3중 for문을 쓰기에는 어려울수도 있으나 ..
자세한 정보 클릭 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..
자세한 정보 클릭 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 이 문제는 아스키코드에 대한 이해가 있었다면 쉽게 접근할 수 있는 문제였다. 이 문제..
자세한 정보 클릭 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
자세한 정보 클릭 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 함수를 처음 써봤는데 중복을 제거하는 부분에 있어서는 굉장히 유용한 함수라고 ..