Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

Coding Guidelines and Sample Codes

For all of the problems on InterviewBit, we do not require you to write a main function / Main class.


You are not required to read input, but instead use the arguments passed to your function. You are not required to print the desired values, but instead return the data as defined by the function signature.


Lets say you were given the problem of adding 2 number a and b.

          Example:

          a : 2
          b : 3

          Output : 5

        

The code will go like this :

CPP

          int add(int a, int b) {
            return a + b;
          }

        

C

          int add(int a, int b) {
            return a + b;
          }

        

Python

          class Solution:
            def add(a, b):
            return a + b

        

Java

        public class Solution {
            public int add(int a, int b) {
                return a + b;
            }
        }
        

For all of the problems of Bash on InterviewBit, incase you have to take input, please take it from file named 'input' (without quotes). Print your final output to console.


Lets say you were given the problem of adding two numbers which are in the first line of the file named 'input'

          Example:

          Input:
          2 3

          Output : 5

        

Bash

         #!/bin/bash

         a=$(cat input| head -n 1 | awk '{print $1}')
         b=$(cat input| head -n 1 | awk '{print $2}')
         echo $((a+b))
        
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Graduation Year *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+91 *
+91
Change Number
Phone Number *
OTP will be sent to this number for verification
+91 *
+91
Change Number
Graduation Year *
Graduation Year *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test
Click here to start solving coding interview questions
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Graduation Year *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+91 *
+91
Change Number
Phone Number *
OTP will be sent to this number for verification
+91 *
+91
Change Number
Graduation Year *
Graduation Year *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test