본문 바로가기
1 Day 1 Algorithms

[2018.12.11] Solve Me First

by 곰돌찌 2018. 12. 14.

Problem


complete the function solveMeFirst to compute the sum of two integers


Function prototype:

int solveMeFirst(int a, int b);

where,

  • a is the first integer input.
  • b is the second integer input

Return values

  • sum of the above two integers

Sample Input

a = 2
b = 3

Sample Output

5

Explanation

The sum of the two integers  and  is computed as: .


How I solved the problem

## 단순히 더해서 리턴하는 문제!


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
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);
   }
}
 
cs


[출처 : https://www.hackerrank.com ]

'1 Day 1 Algorithms' 카테고리의 다른 글

[2018.12.13] Counting Valleys  (0) 2018.12.14
[2018.12.13] Compare the Triplets  (0) 2018.12.14
[2018.12.12] Sock Merchant  (0) 2018.12.14
[2018.12.12] Simple Array Sum  (0) 2018.12.14
1일 1알고리즘 문제 풀기 Start  (0) 2018.12.14

댓글