Wipro Elite Coding Question Solved

In this post we will see Wipro Elite off campus coding Question asked in elite hiring program. Wipro off campus coding test consists of two coding questions each with 30 minutes time for solving.

Wipro Elite Hiring Coding Question


Farway home is an online platform where users can buyproperti. This platform has a list of N plots numbered 0 to (N-1). The list consists of the specified area for each plot. The platform provoides an application where a user can identify the plots with the kth largest area from the list.

Write an algorithm to find the plot with the kth largest area.

Input:
The first line of the input consists of an integer-size, representing the number of plots (N).

The second line consists of N space separated integers – area0, area1, area2…………areaN-1 , representing the areas of the plots.

The last line consists of an integer value, representing the value for which the user wishes to find area (K).

Output:
Print an integer representing the plot with the Kth largest area.

Constraints
0< values <= size<=106

0<= area<=106
0<= i < size

Example

Input
7

10 5 7 88 19 45 56

3

Output:
45

Explanation:
The sorted areas are [88, 56, 45, 19, 10, 7, 5]. so the 3rd largest area is 45

Algorithm For wipro elite hiring

  1. Algorithm for Solving Wipro Elite coding problem
  2. Initially get the value of N from user which is the total number of sites
  3. Next Take N values from users which represents site areas.
  4. Next enter the value of k.
  5. Here we need to return the kth largest site from the existing site areas.
  6. Congrats you just solved an off capus coding question, solve more all the best.

Java Code for Wipro Elite Hiring Question

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

public class problem29 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("Enter total number of sites (N)");

        int N = sc.nextInt();
        int array1[] = new int[N];
        System.out.println("Enter " + N + "Site areas");


        for (int i = 0; i < N; i++) {

            array1[i] = sc.nextInt();

        }
        System.out.println("Enter the value of k ");
        int k = sc.nextInt();

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

            if (array1[j] < array1[j + 1]) {
                int temp = array1[j];
                array1[j] = array1[j + 1];
                array1[j + 1] = temp;
                j = -1;
            }
        }
        System.out.println(array1[k - 1]);

    }

}

To get More Explanation on java code, visit our channel

3 thoughts on “Wipro Elite Coding Question Solved”

  1. Pingback: Complete Solution For Rob And Mars Problem In Java - Is It Actually

  2. Pingback: Count Buildings Hacker Earth coding question with solution - Is It Actually

Leave a Comment

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