반응형 분류 전체보기327 [프로그래머스 - JAVA] 숫자 찾기 내 풀이 class Solution { public int solution(int num, int k) { int answer = 0; String word = ""+num; for (int i = 0; i < word.length(); i++) { if(String.valueOf(k).equals(String.valueOf(word.charAt(i)))){ answer = i+1; break; }else { answer = -1; } } return answer; } } 단순하게 for문을 이용한 index 찾기 class Solution { public int solution(int num, int k) { int answer = 0; String word = ""+num; answer = word... 2023. 3. 11. [프로그래머스 - JAVA] 약수 구하기 * 참고 : 약수는 어떤 수를 나누어 딱 떨어지는 수를 말한다. 내 풀이 import java.util.stream.IntStream; class Solution { public int[] solution(int n) { int[] answer = {}; int count = 0; answer = new int[(int) IntStream.rangeClosed(1 , n).filter(value -> n % value == 0).count()]; for (int i = 1; i (n % i == 0)).toArray(); return answer; } } return 에 IntStream.rangeClosed(1, n).filter(i -> (n % i == 0)).toArray(); 한줄로도 해결이 되.. 2023. 3. 11. [프로그래머스 - JAVA] 369게임 내 풀이 class Solution { public int solution(int order) { int answer = 0; String word = "" + order; for (int i = 0; i < word.length(); i++) { if("369".contains(String.valueOf(word.charAt(i)))){ answer++; } } return answer; } } 나머지를 구하는 방식도 사용하였는데 다른 분들의 코드 참고. 대부분 풀이는 나머지를 구하는 방식이거나 equals 또는 charAt 비교였다. 나처럼 contains 사용하신분이 안보이던데...연산 차이가 좀 있으려나?? 다른 사람 풀이 class Solution { public int solution(int .. 2023. 3. 11. [프로그래머스 - JAVA] 피자 나눠 먹기(2) 내 풀이 class Solution { public int solution(int n) { int answer = 0; int count = 1; while (true) { if (n % 6 == 0) { answer = n / 6; break; } else if ((count * 6) % n == 0) { answer = (count * 6) / 6; break; } count++; } return answer; } } 제출하고보니 if문이 하나여도 충분했고 else if 문에 answer = count 를 넣으면 될 것을 왜 저런 뻘짓을 했는지...졸리긴 한가보다 새로운 count 변수도 사용하지 않고 주어진 answer를 이용하는 쪽으로 해야겠다. 다른 사람 풀이 class Solution { pu.. 2023. 3. 10. [Spring Boot] log4j 설정 application.properties #### Database # oracle spring.datasource.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy spring.datasource.url=jdbc:log4jdbc:oracle:thin:@localhost:1521/XE spring.datasource.username=system spring.datasource.password=0000 # mysql spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy spring.datasource.url=jdbc:mysql://127.0.0.1:3306/demo?autoReconn.. 2023. 3. 10. [Spring Boot] application.properties(oracle연동, devtools, thymeleaf) # 포트 지정server.port=9090#### Databasespring.datasource.driver-class-name=oracle.jdbc.OracleDriverspring.datasource.url=jdbc:oracle:thin:@localhost:1521/XEspring.datasource.username=systemspring.datasource.password=0000#### thymeleafspring.thymeleaf.prefix=classpath:templates/spring.thymeleaf.check-template-location=truespring.thymeleaf.suffix=.htmlspring.thymeleaf.mode=HTML5spring.thymeleaf.cache.. 2023. 3. 10. 이전 1 ··· 50 51 52 53 54 55 다음 반응형