Wipro Elite off campus coding Question

In this post we will see the wipro elite off campus coding question which is asked in 30 minute section. we will see step by step solution for wipro elite hiring in java language.

Wipro Elite Question

For the current academic session, a university has decided to allocate grades to the students based on their marks obtained in the exam. The whole process will be automated and will be done by the university system. At first the system takes in the list of N subject marks obtained by the student. Then, the system will output the kth smallest marks from the list.

Write an algorithm to output the kth smallest marks from the list.


The first line of the input consists of an integer – numSubjects, representing the number of subjects(N).

The second line consists of N space separated integers –marks

Marks1——marksN-1, representing the marks obtained by the students in N subjects.

The last line consists of an integer value, representing the value (k) for which the marks need to be determined.


Print an integer representing the kth smallest marks in N subjects.


0<value<= numSubjects<=10 power 6

0<=marks<=10 power 6

0<= I<= numSubjects




10 5 7 88 19 26 6





The sorted list of marks is {5 6 7 10 19 26 88}

So the 5th smallest marks in 19

wipro elite coding question

Coding Algorithm :

  1. The first line of input consists of Number of subjects let us denote as N
  2. The second line of input consists of N space separated Integers representing the Marks obtained by students in N subjects.
  3. The last line of input consists of value of k for which we need to determine the value.
  4. Here once we get all inputs from user then get the sorted array (Ascending order).
  5. Then find the k-1 index value in array which is the kth smallest marks which is required output.
  6. ongrats you just solved an off campus coding question.

JAVA Code for Above wipro elite question

import java.util.Scanner;
import java.util.Arrays;

public class problem24 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the number of subjects (N)");
        int N = sc.nextInt();
        int array1[] = new int[N];
        int counter = 0;
        System.out.println("Enter the value of kth smallest integer");
        int k = sc.nextInt();
        System.out.println("Enter the marks for each subjects ");

        for (int i = 0; i &lt; N; i++) {

            array1[i] = sc.nextInt();


        for (int j = 0; j &lt; array1.length-1; j++) {

            if (array1[j] &gt; array1[j+1]) {
                int temp = array1[j];
                array1[j] = array1[j+1];
                array1[j+1] = temp;
                j = -1;





Check out video for more explanation on code below

Leave a Comment

Your email address will not be published. Required fields are marked *