Solve Me First | HackerRank Solution

Hello coders, today we are going to solve Solve Me First HackerRank Solution which is a part of HackerRank Algorithms Series.

Contents

Task

Complete the function solveMeFirst to compute the sum of two integers.

Example

a = 7
b = 3

Return 10.

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 a and b

Constraints

  • 1 <= a, b <= 1000

Sample Input

a = 2
b = 3

Sample Output

5

Explanation

2 + 3 = 5

Solution – Solve Me First

C++

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int solveMeFirst(int a, int b) {
 // Hint: Type return a+b; below:
  return a + b;
}

int main() {
  int num1, num2;
  int sum;
  cin>>num1>>num2;
  sum = solveMeFirst(num1,num2);
  cout<<sum;
  return 0;
}

Python

def solveMeFirst(a,b):
	# Hint: Type return a+b below
    return a + b

num1 = int(input())
num2 = int(input())
res = solveMeFirst(num1,num2)
print(res)

Java

import java.util.Scanner;

public class SolveMeFirst {

    static int solveMeFirst(int a, int b) {
        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);
        in.close();
   }
}

Disclaimer: The above Problem (Solve Me First) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

Leave a Comment

Your email address will not be published.