Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 코딩테스트
- Method
- two pointers
- dynamic programming
- 자바
- Matrix
- 구현
- Stack
- Math
- greedy
- sorting
- geometry
- hash table
- database
- Binary Tree
- java
- Data Structure
- Number Theory
- 파이썬
- 코테
- bit manipulation
- array
- implement
- simulation
- Class
- Tree
- Counting
- SQL
- string
- Binary Search
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 간단한 식 계산하기 본문
1. Input, Output, Example
binomial은 "a op b" 형태의 이항식이고 a와 b는 음이 아닌 정수, op는 '+', '-', '*' 중 하나이다.
- 주어진 식을 계산한 정수를 반환
2. Constraint
1) 0 ≤ a, b ≤ 40,000
2) 0을 제외하고 a, b는 0으로 시작하지 않는다.
3. Code
1) 첫 코드(2023/04/27)
import java.util.*;
class Solution {
public int solution(String binomial) {
StringTokenizer st = new StringTokenizer(binomial);
int a = Integer.valueOf(st.nextToken());
String op = st.nextToken();
int b = Integer.valueOf(st.nextToken());
switch(op){
case "+": return a+b;
case "-": return a-b;
default: return a*b;
}
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] qr code (0) | 2023.04.27 |
---|---|
[프로그래머스/Lv.0] 왼쪽 오른쪽 (0) | 2023.04.27 |
[프로그래머스/Lv.0] 배열의 원소만큼 추가하기 (0) | 2023.04.27 |
[프로그래머스/Lv.0] 접미사 배열 (0) | 2023.04.27 |
[프로그래머스/Lv.0] 뒤에서 5등까지 (0) | 2023.04.27 |