일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- Python
- programmers
- 리액트
- redux
- Algorithm
- 항해플러스
- sw expert academy
- java
- react-router
- react-redux
- C++
- SW
- redux-saga
- maeil-mail
- redux-toolkit
- axios
- 자바
- createSlice
- 이코테
- 코딩테스트합격자되기
- 항해99
- 테코테코
- JavaScript
- json-server
- Get
- react
- 알고리즘
- 매일메일
- useDispatch
- 프로그래머스
- Today
- Total
목록Python (143)
Binary Journey
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges 등차수열 문제였다. ** Java 1) 이건 내 첫번째 풀이였다. class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; for (int i = 0; i < n; i++) { answer[i] = Long.valueOf(x) + Long.valueOf(x) * Long.valueOf(i); } return answer; } } 위 소스를 보면 자료형 때문에 Long.valueOf 을 쓴 걸 볼 수 있는데 애초에 input 을 long 으로 받으면 될 문제였다. 2) 그래서 수정한 풀이는 이렇게 ..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Java Java로는 다음과 같이 작성하였다. import java.util.Scanner; public 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 < b; i++) { for (int j = 0; j < a; j++) { System.out.printf("*"); } System.out.println(); } } } 대략 1800명이 같은 풀이로 통..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 3진법이라는 알았는데 for문으로 접근했다가 시간을 너무 오래 잡아먹었다. 결국 구글링해서 답을 알아냈는데 생각보다 더 간단했다. while 을 사용하면 이렇고 function solution(n) { const availableNumber = [ 4, 1, 2 ]; let answer = ''; while (n) { answer = availableNumber[n % 3] + answer; n = n % 3 ? Math.floor(n / 3) : n / 3 - 1; } return answer; } 더 줄이면 이렇게 된다. 추천 가장 많이 받은 식인데 재귀함수 방..