TeachingBee

10 Wipro Coding Questions That You’ll Be Definitely Asked

wipro coding questions

Wipro Elite National Talent Hunt (NTH)

Wipro Elite National Talent Hunt (NTH) is a newcomer’s recruitment initiative that aims to recruit the top engineers across the nation.The aim of this program is to ensure equal opportunity to the best talent in Computer Science, Information Technology and Circuital Engineering fields in India. A person who is interested in engineering must not miss the chance to join an amazing journey at Wipro!.

This article will focus mainly on Wipro coding questions and topics asked in previous years. But first let’s look into test pattern and interview rounds.

Procedure

SectionNo. of QuestionsDuration
Aptitude50-6048 minutes
Online Programming Test260 minutes
Essay Writing120 minutes
Business Discussion Round ( Technical + HR)30 minutes

Types Of Wipro Coding Questions

Types of Questions
Pattern Based Questions
Searching And Sorting
Arrays
GCD And HCF
Other Function Based Questions Like Prime Number,  fibonacci etc
Basic String Questions

Wipro Coding Questions

1. Distinct Elements In An Array

Problem Statement

Given an unsorted array of integers print each distinct element in the array. The array could have duplicates, and the output should print each element once.

Examples:

Input: arr[] = {12, 50, 9, 45, 2, 50, 50, 45}
Output: 12, 50, 9, 45, 2

Input: arr[] = {1, 2, 3, 4, 5, 6, 7}
Output: 1, 2, 3, 4, 5, 6, 7

Input: arr[] = {2, 2, 2, 2, 2}
Output: 2

Solution

The idea is to use hashing to keep track of elements that are visited.
If element is not present in hash table print the element and insert into hash table else ignore.

Implementation

// Wipro Coding Questions: Distinct Elements In An Array
    static void printAllDistinctElements(int arr[])
    {
        // Creates a Hashset
        HashSet<Integer> hashTable = new HashSet<>();
 
        // Traverse the array
        for (int i=0; i<arr.length; i++)
        {
            // If not present, then put it in hash table and print it
            if (!hashTable.contains(arr[i]))
            {
                hashTable.add(arr[i]);
                System.out.print(arr[i] + " ");
            }
        }
    }

2. Parenthesis Checker

Problem Statement

If you have a string that contains only two characters ‘(‘, ‘)’, ”, “[ [‘, ‘]’, determine whether that string has valid parenthesis or not .

A input string can be considered to have valid parenthesis if:

  1. Closed brackets need to be closed with the same brackets.
  2. Open brackets need to be closed in the proper order.

Examples:

Input: s = “[()]{}{[()()]()}” 
Output: true

Input: s = “[(])” 
Output: false 

Solution

1) Declare a character Stack Then, go through the string of expression exp.
2) If the character currently displayed is a beginning bracket ( '(' or '{'or '[') then push it up
to the stack.
3) If the character you are currently reading is an ending bracket ( ')' or '}' or ']') then pop off the stack.
4) If the character that is popped is the starting bracket that matches, then the brackets in fine else aren't well-balanced.
5) After traversal complete If there's any remaining bracket in the stack, then "not balanced"

// Wipro Coding Questions: Parenthesis Checker
  public boolean isValid(String s) {
      
      if (s == null || s.length() <= 1) return false;
      Map < Character, Character > map = new HashMap < > () {
          {
              put(')', '(');
              put(']', '[');
              put('}', '{');
          }
      };

     // Create A Stack
      Stack < Character > stack = new Stack < > ();
     // Traverse through String
      for (char c: s.toCharArray()) {
          // If character is closing brackets, check for corresponding opening brackets
          if (c == ')' || c == ']' || c == '}') {
              if (stack.isEmpty() || stack.pop() != map.get(c)) return false;
          } else stack.push(c);
      }
      return stack.isEmpty();
  }

3. Sort Array In Ascending and Descending Pattern

Problem Statement

Given an array of integers, sort the first half of the array in ascending order and second half in descending order.


Examples: 

Input : arr[] = {10, 20, 30, 40}
Output : arr[] = {10, 20, 40, 30}

Input : arr[] = {5, 4, 6, 2, 1, 3, 8, 9, 7 }
Output : arr[] = {2, 4, 5, 6, 9, 8, 7, 3, 1 }

Solution

Sort the whole array in ascending order in group of two halves
Reverse the second half after sorting. 

// Wipro Coding Questions: Sort Array In Ascending and Descending Pattern
static void sortFunc(Integer[] arr)
    {
        int n = arr.length;
         
        // Sort the array in half
        Arrays.sort(arr, 0, n/2);
        Arrays.sort(arr, n/2, n);
 
        // Reverse the second half
        int low = n/2, high = n-1;
        while (low < high)
        {
            Integer temp = arr[low];
            arr[low] = arr[high];
            arr[high] = temp;
            low++; high--;
        } 
    }

4. Count Number of 1’s

Problem Statement

Convert a Decimal Number to Binary & Count the Number of 1s in it

Examples:

Input. 1: 10
Output 1: The binary equivalent of 10 is : 1010
          Number of 1s is : 2

Input  2: 15
Output 2: The binary equivalent of 15 is : 1111
          Number of 1s is 4

Solution

Convert Number to Binary by Dividing the decimal number by 2. Check whether the the remainder is 1 or not. If yes, increment the count.

// Wipro Coding Questions: Count Number of 1's
 
  static void convertAndCount(int num) {
      int temp = num; // a temporary variable to store the
      // value of num

      // to store the count of 1s
      int count = 0;

      // to iterate through the loop 
      while (temp > 0) {

          // check the remainder
          int remainder = temp % 2;

          // If 1 is present in binary
          if (remainder == 1)

              // increment the count
              count++;

          // divide the number by 2  
          temp /= 2;
      }

      // Printing number of 1's
      System.out.println("\nNumber of 1s is : " + count);
  }

5. Sum of Digits

Problem Statement

Given a number n. Print the sum of digit of number n.

Examples:

Input : n = 687
Output : 21

Input : n = 134
Output : 8

Solution

1) Initialise variable sum to 0
2) Divide the number by 10 and add the remainder to variable sum
3) Assign number/10 to number
4) Repeat till number becomes 0
// Wipro Coding Questions: Sum of Digits
static void sumOfDigits(int num) {
    int sum = 0;
    // Loop until num is greater than 0
    while (num > 0) {
       // Get the remainder
        sum += num % 10;
        // change num to num/10
        num /= 10;
    }
    System.out.println("Sum of Digit is: " + sum);
}

6. Print Prime Numbers

Problem Statement

Given a number N, the task is to print the prime numbers from 1 to N.


Examples: 

Input: N = 10
Output: 2, 3, 5, 7

Input: N = 5
Output: 2, 3, 5 

Solution

First, take the number N as input.Loop through the numbers from 1 to N and check for each number to be a prime number.
If it is a prime number, print it.To check a number is prime or not. Run a loop from 2 to square root of number. If the number is divisible by i, then n is not a prime number.

 // Wipro Coding Questions: Print Prime Numbers
static boolean checkPrime(int n) {
     //since 0 and 1 is not prime return false.
     if (n == 1 || n == 0) return false;

     //Run a loop from 2 to square root of n
     for (int i = 2; i * i <= n; i++) {
         // if the number is divisible by i, then n is not a prime number.
         if (n % i == 0) return false;
     }
     //otherwise, n is prime number.
     return true;
 }


 // print prime numbers
 static void printPrimeNumbers(int N) {
     //check for every number from 1 to N
     for (int i = 1; i <= N; i++) {
         //check if current number is prime
         if (checkPrime(i)) {
             System.out.print(i + " ");
         }
     }

 }

7. Sum of Subarray

Problem Statement

Given an array of n elements and two integers P and Q. Print sum of numbers from Pth index to Qth index (both inclusive)

Examples:

Input: {1,2,3,4,5,6,7}, P= 2, Q=5
Output:
2+3+4+5= 14

Solution

Initialise sum=0
Iterate through array.
If index is between P and Q, add array value to sum variable.

// Wipro Coding Questions: Sum of Subarray
static void sumOfSubarray(Integer[] arr, int p, int q) {
    int sum = 0;
    for (int i = 0; i < arr.length; i++) {
        
        // Since array is 0 based indexed therefore p-1 and q-1 are compared
        if (i >= p - 1 && i <= q - 1) {
            sum += arr[i];
        }
    }
    System.out.println("Sum is:" + sum);
}

8. Maximum Occurring Character In String

Problem Statement

Given a input string return maximum occurring character in the input string 

Examples:

Input: "aabbbcc"
Output: b

Solution

Create a count array to store frequency of each character.
Iterate through count array to get maximum count character

// Wipro Coding Questions: Maximum Occurring Character In String
static void getMaxOccuringChar(String str) {
    // Create array to keep the count of individual
    // characters and initialize the array as 0
    int count[] = new int[256];

    // Construct character count array from the input
    // string.
    int len = str.length();
    for (int i = 0; i < len; i++)
        count[str.charAt(i)]++;

    int max = -1; // Initialize max count
    char result = ' '; // Initialize result

    // Traversing through the cout array to get maximum count character
    for (int i = 0; i < 256; i++) {
        if (max < count[i]) {
            max = count[i];
            result = (char) i;
        }
    }

    System.out.println("Character is:" + result);
}

9. Sum of Modulus

Problem Statement

Given an array and integer M. Find the sum of modulus of each array element with M.

Examples:

Input: {1,2,3,4,5,6}, M=3
Output: 1+2+0+1+2+0=6

Solution:

Initialise sum to 0. Iterate through array and keep adding arr[i]%M to sum

// Wipro Coding Questions: Sum of Modulus
static void sumOfModulus(Integer[] arr, int M) {
    int sum = 0;
    for (Integer num: arr) {
        sum += (num % M);
    }
    System.out.println("Sum is:" + sum);
}

10. Maximum Sum Of k Numbers

Problem Statement

Given an unordered array. Find the Maximum sum of k elements of array.

Examples:

Input: {1,2,3,4,5,6}, M=3
Output: 4+5+6=15

Solution:

Initialise sum to 0.
Sort the array in ascending order and add k elements from back.

// Wipro Coding Questions: Sum of Modulus
static void sumOfKElements(Integer[] arr, int k) {
    if (k >= arr.length)
        return;
    int sum = 0;
    Arrays.sort(arr);
    int i = arr.length - 1;
    while (k > 0) {
        sum += arr[i];
        i--;
        k--;
    }
    System.out.println("Sum is:" + sum);
}

11. Rotate The Array

Checkout best algorithm for array rotation here.

12. k’th Smallest Number

The detailed solution can be found here.

Conclusion

For more courses and certifications do checkout examlabs. They offer quality and affordable training programs.

In this article we covered various types of Wipro coding questions. Hope you all got idea about questions asked in Wipro coding round.

Got a question or just want to chat? Comment below or drop by our forums, where a bunch of the friendliest people you’ll ever run into will be happy to help you out!

90% of Tech Recruiters Judge This In Seconds! 👩‍💻🔍

Don’t let your resume be the weak link. Discover how to make a strong first impression with our free technical resume review!

Related Articles

Rust for AI-teachingbee

Is Rust Good for AI?

Artificial Intelligence (AI) has revolutionised various industries, from healthcare to finance, by enabling machines to perform tasks that typically require human intelligence. As the demand for AI solutions continues to

salary of Rust programmer in India-teachingbee

What is the salary of Rust programmer in India?

Rust is a modern, statically typed programming language designed for performance, safety, and concurrency. Developed by Mozilla, Rust offers memory safety without a garbage collector, making it suitable for systems

Why Aren’t You Getting Interview Calls? 📞❌

It might just be your resume. Let us pinpoint the problem for free and supercharge your job search. 

Newsletter

Don’t miss out! Subscribe now

Log In