Skip to content
Programmingoneonone
Programmingoneonone

LEARN EVERYTHING ABOUT PROGRAMMING

  • Home
  • CS Subjects
    • IoT ? Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

LEARN EVERYTHING ABOUT PROGRAMMING

Hackerrank Intro to Tutorials Challenges problem solution

YASH PAL, 31 July 2024

In this Hackerrank Intro to Tutorial Challenges problem we have given a sorted array and a number, we need to print the index location of the integer in the array.

Hackerrank Intro to Tutorials Challenges problem solution

Topics we are covering

Toggle
  • Problem solution in Python programming.
  • Problem solution in Java Programming.
    • Problem solution in C++ programming.
    • Problem solution in C programming.
    • Problem solution in JavaScript programming.

Problem solution in Python programming.

#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'introTutorial' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
#  1. INTEGER V
#  2. INTEGER_ARRAY arr
#

def introTutorial(V, arr):
    return arr.index(V)

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    V = int(input().strip())

    n = int(input().strip())

    arr = list(map(int, input().rstrip().split()))

    result = introTutorial(V, arr)

    fptr.write(str(result) + 'n')

    fptr.close()

Problem solution in Java Programming.

import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
        int value = sc.nextInt();
        int cas = sc.nextInt();
        ArrayList<Integer> ar = new ArrayList<Integer>();
        for(int i = 0;i<cas; i++)
        {
            ar.add(sc.nextInt());
        }
        
        for(int n = 0; n < ar.size();n++)
        {
            if(ar.get(n) == value)
                System.out.println(n);
        }
    }
}

Problem solution in C++ programming.

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


int main() {
    
    int V, n, temp;
    cin >> V;
    cin >> n;
    
    int array[n];
    
    for(int i = 0; i < n; i++) {
        cin >> temp;
        array[i] = temp;  
    }
    for(int i = 0; i < n; i++) {
        if(array[i] == V) {
            cout << i << endl;;
        }
        
    }
  
    
    
    return 0;
}

Problem solution in C programming.

#include <stdio.h>
#include <string.h>
int main()
{
	int V,N,a;
	scanf("%d%d",&V,&N);
	int i;
	for(i = 0; i < N; i ++)
	{
		scanf("%d",&a);
		if(a == V)
		{
			printf("%dn",i);
			return 0;
		}
	}
	printf("-1n");
	return 0;
}

Problem solution in JavaScript programming.

function processData(input) {
    //Enter your code here
    var inputArray = input.split('n');
    var V = parseInt(inputArray[0], 10);
    var valueArray = inputArray[2].split(" ");
    for(var i =0; i<valueArray.length; i++){
        if(parseInt(valueArray[i],10) === V){
            console.log(i);
            break;
        }
    }
} 

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

Algorithms coding problems solutions

Post navigation

Previous post
Next post
  • Automating Image Format Conversion with Python: A Complete Guide
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes