반응형
츄르사려고 코딩하는집사입니다.
1. [HackerRank] Solve Me First 자바(JAVA)
2. 문제 출처
https://www.hackerrank.com/challenges/solve-me-first/problem
3. 문제
Complete the function solveMeFirst to compute the sum of two integers.
Example
Return .
Function Description
Complete the solveMeFirst function in the editor below.
solveMeFirst has the following parameters:
- int a: the first value
- int b: the second value
Returns
- int: the sum of and
Constraints
Sample Input
a = 2 b = 3
Sample Output
5
Explanation
4. 풀이
- 단순한 변수 입력 받은 것을 return a+b;를 해주면 된다.
5. 소스 코드
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int solveMeFirst(int a, int b) {
// Hint: Type return a+b; below
return a+b;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a;
a = in.nextInt();
int b;
b = in.nextInt();
int sum;
sum = solveMeFirst(a, b);
System.out.println(sum);
}
}
반응형
'알고리즘 > HackerRank' 카테고리의 다른 글
[HackerRank] Top Earners 오라클(Oracle) (1) | 2024.01.31 |
---|---|
[HackerRank] The Blunder 오라클(Oracle) (0) | 2024.01.31 |
[HackerRank] Revising the Select Query I 오라클(Oracle) (0) | 2023.07.03 |
[HackerRank] Revising Aggregations - The Count Function 오라클(Oracle) (0) | 2022.10.19 |
[HackerRank] Population Density Difference 오라클(Oracle) (0) | 2021.09.27 |
[HackerRank] Japan Population 오라클(Oracle) (0) | 2021.09.27 |
[HackerRank] Average Population 오라클(Oracle) (0) | 2021.09.23 |
[HackerRank] Revising Aggregations - Averages 오라클(Oracle) (0) | 2021.09.23 |
최근댓글