Wipro Coding Questions: Practice and Prepare for Interviews

Published: 16 Dec 2024 | Reading Time: 10 min

Overview

Wipro is one of India's leading IT services companies that conducts a variety of coding rounds during its recruitment process. The coding round is an essential part of the hiring process to evaluate a candidate's problem-solving and coding abilities. Whether you're preparing for the Wipro assessment test coding questions or specifically focusing on Wipro coding interview questions, understanding the types of questions and the strategies to crack them can significantly boost your chances of success.

As one of the most sought-after companies for freshers and experienced professionals, Wipro's selection process has evolved to include challenging coding questions. These questions are designed to assess a candidate's technical problem-solving skills, logical thinking, and proficiency in programming languages. For candidates aiming to get through Wipro's coding test or coding interview, focusing on practice and mastering coding fundamentals is crucial.

Table of Contents

Importance of Wipro Coding Questions for Candidates

The Wipro coding questions hold significant importance because they test not just your knowledge of programming languages, but also your ability to think critically and solve complex problems. Whether it's Wipro milestone coding questions or the ones asked during Wipro placement coding questions, mastering them can help you secure your place in the company.

What the Coding Round Evaluates

The coding round typically evaluates:

A good grasp of these elements will give you an edge in the competitive hiring process.

Beginner Level Wipro Coding Question and Answers

For those just starting their Wipro coding preparation, focusing on fundamental concepts is key. Here are five beginner-level Wipro coding questions with complete solutions:

Problem 1: Add Two Large Numbers Represented as Strings

Problem Statement: You are given two strings, each representing a large number. Write a program to calculate the sum of these two numbers. Each string contains digits only and can be of different lengths. The result should be returned as a string, and no leading zeroes should be present in the result.

Test Cases:

Input Output
First number: 123, Second number: 456 579
First number: 999, Second number: 1 1000

Solution in C:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char* addStrings(char* num1, char* num2) {
    int len1 = strlen(num1), len2 = strlen(num2);
    int maxLen = (len1 > len2) ? len1 : len2;
    char* result = (char*)malloc((maxLen + 2) * sizeof(char)); // Extra space for carry
    int carry = 0, i, j, k = 0;

    for(i = len1 - 1, j = len2 - 1; i >= 0 || j >= 0 || carry; i--, j--) {
        int digit1 = (i >= 0) ? num1[i] - '0' : 0;
        int digit2 = (j >= 0) ? num2[j] - '0' : 0;
        int sum = digit1 + digit2 + carry;
        carry = sum / 10;
        result[k++] = (sum % 10) + '0';
    }
    result[k] = '\0';

    // Reverse result string
    for(i = 0, j = k - 1; i < j; i++, j--) {
        char temp = result[i];
        result[i] = result[j];
        result[j] = temp;
    }

    return result;
}

int main() {
    char num1[1000], num2[1000];
    printf("Enter first number: ");
    scanf("%s", num1);
    printf("Enter second number: ");
    scanf("%s", num2);

    char* sum = addStrings(num1, num2);
    printf("Sum: %s\n", sum);
    free(sum);
    return 0;
}

Problem 2: Largest Product of Two Distinct Numbers

Problem Statement: You are given an array of integers. Write a program to find the largest product of any two distinct numbers in the array. The program should handle both positive and negative numbers. If the array contains fewer than two elements, return a suitable message indicating that it's not possible to calculate the product.

Test Cases:

Input Output
n = 4, arr[] = 1 2 3 4 12
n = 4, arr[] = -10 -3 5 6 30

Solution in C:

#include <stdio.h>

int largestProduct(int arr[], int n) {
    int max1 = arr[0], max2 = arr[1], min1 = arr[0], min2 = arr[1];

    for(int i = 2; i < n; i++) {
        if(arr[i] > max1) {
            max2 = max1;
            max1 = arr[i];
        } else if(arr[i] > max2) {
            max2 = arr[i];
        }

        if(arr[i] < min1) {
            min2 = min1;
            min1 = arr[i];
        } else if(arr[i] < min2) {
            min2 = arr[i];
        }
    }

    return (max1 * max2 > min1 * min2) ? max1 * max2 : min1 * min2;
}

int main() {
    int n;
    printf("Enter number of elements: ");
    scanf("%d", &n);

    int arr[n];
    printf("Enter %d elements: ", n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    printf("Largest product: %d\n", largestProduct(arr, n));
    return 0;
}

Problem 3: Reverse Words in a Sentence

Problem Statement: Write a program that reverses the words in a given sentence. The characters within each word should retain their order, but the words themselves should appear in reverse order. Handle edge cases like empty strings or strings with only one word. Ensure that multiple spaces between words are reduced to a single space.

Test Cases:

Input Output
Hello World olleH dlroW
Wipro orpiW

Solution in C:

#include <stdio.h>
#include <string.h>

void reverseWords(char* str) {
    int length = strlen(str);
    int start = 0, end = 0;

    while (end <= length) {
        if (str[end] == ' ' || str[end] == '\0') {
            int tempStart = start, tempEnd = end - 1;
            while (tempStart < tempEnd) {
                char temp = str[tempStart];
                str[tempStart] = str[tempEnd];
                str[tempEnd] = temp;
                tempStart++;
                tempEnd--;
            }
            start = end + 1;
        }
        end++;
    }
}

int main() {
    char str[1000];
    printf("Enter a sentence: ");
    fgets(str, sizeof(str), stdin);
    str[strcspn(str, "\n")] = '\0';  // Remove the newline character

    reverseWords(str);
    printf("Reversed Words: %s\n", str);
    return 0;
}

Problem 4: Find Second Largest Element in Array

Problem Statement: Given an unsorted array of integers, write a program to find the second largest element in the array. If there is no second-largest element (such as when all elements are equal), the program should return an appropriate message indicating the absence of a second-largest number.

Test Cases:

Input Output
n = 5, arr[] = 10 20 4 45 99 45
n = 5, arr[] = 1 1 1 1 No second largest element

Solution in C:

#include <stdio.h>

int secondLargest(int arr[], int n) {
    if(n < 2) return -1;
    int largest = arr[0], secondLargest = -1;
    for(int i = 1; i < n; i++) {
        if(arr[i] > largest) {
            secondLargest = largest;
            largest = arr[i];
        } else if(arr[i] > secondLargest && arr[i] != largest) {
            secondLargest = arr[i];
        }
    }
    return secondLargest;
}

int main() {
    int n;
    printf("Enter number of elements: ");
    scanf("%d", &n);

    int arr[n];
    printf("Enter %d elements: ", n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    int result = secondLargest(arr, n);
    if (result == -1)
        printf("No second largest element\n");
    else
        printf("Second largest: %d\n", result);

    return 0;
}

Problem 5: Remove Duplicates from Sorted Array

Problem Statement: You are given a sorted array of integers. Write a function to remove duplicates from the array, ensuring that the remaining elements are placed in the original positions of the array. The function should return the new length of the array after removing duplicates. The array should be modified in place.

Test Cases:

Input Output
n = 6, arr[] = 1 1 2 3 3 4 4
n = 4, arr[] = 0 0 0 0 1

Solution in C:

#include <stdio.h>

int removeDuplicates(int arr[], int n) {
    if(n == 0) return 0;
    int j = 0;
    for(int i = 1; i < n; i++) {
        if(arr[i] != arr[j]) {
            j++;
            arr[j] = arr[i];
        }
    }
    return j + 1;
}

int main() {
    int n;
    printf("Enter number of elements: ");
    scanf("%d", &n);

    int arr[n];
    printf("Enter %d elements: ", n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    int newLength = removeDuplicates(arr, n);
    printf("New length: %d\n", newLength);
    return 0;
}

Advanced Level Wipro Coding Question and Answers

As you advance in your preparation for Wipro coding questions, you'll encounter more complex problems. Here are ten advanced-level Wipro coding questions with complete solutions:

Problem 6: Array Intersection

Problem Statement: Write a program that takes two arrays of integers and finds their intersection. The intersection should contain unique elements that are common in both arrays. You may assume that each element in the arrays is unique. Return the result as a new array, maintaining the order of elements in the first array.

Test Cases:

Input Output
n1 = 4, arr1[] = 1 2 3 4, n2 = 4, arr2[] = 3 4 5 6 3 4
n1 = 3, arr1[] = 1 2 3, n2 = 3, arr2[] = 4 5 6 []

Solution in C:

#include <stdio.h>

void intersection(int arr1[], int n1, int arr2[], int n2) {
    for(int i = 0; i < n1; i++) {
        for(int j = 0; j < n2; j++) {
            if(arr1[i] == arr2[j]) {
                printf("%d ", arr1[i]);
                break;
            }
        }
    }
}

int main() {
    int n1, n2;
    printf("Enter number of elements in first array: ");
    scanf("%d", &n1);
    int arr1[n1];
    printf("Enter %d elements for first array: ", n1);
    for(int i = 0; i < n1; i++) {
        scanf("%d", &arr1[i]);
    }

    printf("Enter number of elements in second array: ");
    scanf("%d", &n2);
    int arr2[n2];
    printf("Enter %d elements for second array: ", n2);
    for(int i = 0; i < n2; i++) {
        scanf("%d", &arr2[i]);
    }

    printf("Intersection: ");
    intersection(arr1, n1, arr2, n2);
    return 0;
}

Problem 7: Rotate Array to the Right

Problem Statement: Given an array of integers, write a program that rotates the array to the right by a given number of positions 'k'. The program should handle cases where 'k' is greater than the length of the array by rotating the array multiple times if necessary. Ensure that the array is rotated in-place.

Test Cases:

Input Output
N = 5, arr[] = 1 2 3 4 5, k = 2 4 5 1 2 3
N = 3, arr[] = 1 2 3, k = 1 3 1 2

Solution in C:

#include <stdio.h>

void rotate(int arr[], int n, int k) {
    k = k % n;  // Handle cases where k > n
    int temp[k];

    for(int i = 0; i < k; i++) {
        temp[i] = arr[n - k + i];
    }

    for(int i = n - 1; i >= k; i--) {
        arr[i] = arr[i - k];
    }

    for(int i = 0; i < k; i++) {
        arr[i] = temp[i];
    }
}

int main() {
    int n, k;
    printf("Enter number of elements: ");
    scanf("%d", &n);

    int arr[n];
    printf("Enter %d elements: ", n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    printf("Enter number of positions to rotate: ");
    scanf("%d", &k);

    rotate(arr, n, k);

    printf("Array after rotation: ");
    for(int i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");
    return 0;
}

Problem 8: Longest Substring Without Repeating Characters

Problem Statement: Write a program to find the longest substring in a given string without repeating characters. The program should return the length of the longest substring as well as the substring itself. Handle edge cases like an empty string or a string with all repeating characters.

Test Cases:

Input Output
abcabcbb abc, Length: 3
bbbbb b, Length: 1

Solution in C:

#include <stdio.h>
#include <string.h>

void longestSubstring(char *s) {
    int n = strlen(s);
    int max_len = 0, start = 0;
    int char_index[256] = {0}; // For storing the index of characters

    for (int end = 0; end < n; end++) {
        if (char_index[s[end]] > start) {
            start = char_index[s[end]];
        }
        char_index[s[end]] = end + 1;

        int len = end - start + 1;
        if (len > max_len) {
            max_len = len;
        }
    }

    // Printing the length and substring
    printf("Length: %d\n", max_len);
    for (int i = start; i < start + max_len; i++) {
        printf("%c", s[i]);
    }
    printf("\n");
}

int main() {
    char s[100];
    printf("Enter a string: ");
    scanf("%s", s);

    longestSubstring(s);
    return 0;
}

Problem 9: Check if Number is Palindrome

Problem Statement: Write a program to check if a given number is a palindrome. A palindrome number reads the same backward as forward. The program should return true if the number is a palindrome and false if it is not. Handle both positive and negative numbers.

Test Cases:

Input Output
121 Palindrome
123 Not a palindrome

Solution in C:

#include <stdio.h>

int isPalindrome(int num) {
    int original = num, reversed = 0, remainder;
    if (num < 0) return 0; // Negative numbers are not palindrome

    while (num != 0) {
        remainder = num % 10;
        reversed = reversed * 10 + remainder;
        num /= 10;
    }

    return original == reversed;
}

int main() {
    int num;
    printf("Enter a number: ");
    scanf("%d", &num);

    if (isPalindrome(num)) {
        printf("Palindrome\n");
    } else {
        printf("Not a palindrome\n");
    }
    return 0;
}

Problem 10: Calculate Factorial Using Recursion

Problem Statement: Write a program to calculate the factorial of a given number using recursion. The program should handle numbers of different sizes and return the factorial value as an integer. If the number is 0, the program should return 1 as the factorial of 0 is defined to be 1.

Test Cases:

Input Output
5 120
7 5040

Solution in C:

#include <stdio.h>

long long factorial(int n) {
    if (n == 0) return 1;
    return n * factorial(n - 1);
}

int main() {
    int num;
    printf("Enter a number: ");
    scanf("%d", &num);

    printf("%lld\n", factorial(num));
    return 0;
}

Problem 11: Sum of Matrix Elements

Problem Statement: You are given a 2D array representing a matrix of integers. Write a program to calculate the sum of all the elements in the matrix. Handle cases where the matrix is empty or contains only one row/column.

Test Cases:

Input Output
n1 = 2, arr1[] = 1 2, n2 = 2, arr2[] = 3 4 10
n1 = 2, arr1[] = 1 1, n2 = 2, arr2[] = 1 1 4

Solution in C:

#include <stdio.h>

int sumMatrix(int rows, int cols, int matrix[rows][cols]) {
    int sum = 0;
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            sum += matrix[i][j];
        }
    }
    return sum;
}

int main() {
    int rows, cols;
    printf("Enter number of rows and columns: ");
    scanf("%d %d", &rows, &cols);

    int matrix[rows][cols];
    printf("Enter the matrix elements:\n");
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            scanf("%d", &matrix[i][j]);
        }
    }

    printf("Sum of matrix elements: %d\n", sumMatrix(rows, cols, matrix));
    return 0;
}

Problem 12: Print All Prime Numbers Up to N

Problem Statement: Write a program to print all the prime numbers up to a given number 'n'. The program should check each number from 2 to n to see if it is prime and print it. A prime number is a number greater than 1 that has no divisors other than 1 and itself.

Test Cases:

Input Output
10 2 3 5 7
5 2 3 5

Solution in C:

#include <stdio.h>
#include <stdbool.h>

bool isPrime(int num) {
    if (num <= 1) return false;
    for (int i = 2; i * i <= num; i++) {
        if (num % i == 0) return false;
    }
    return true;
}

int main() {
    int n;
    printf("Enter a number: ");
    scanf("%d", &n);

    printf("Prime numbers up to %d: ", n);
    for (int i = 2; i <= n; i++) {
        if (isPrime(i)) {
            printf("%d ", i);
        }
    }
    printf("\n");
    return 0;
}

Problem 13: Find Missing Number in Sequence

Problem Statement: Given a sequence of numbers from 1 to N, write a program to find the missing number in the sequence. The sequence may have one missing number, and you are expected to return that number. If no number is missing, the program should return a message indicating that the sequence is complete.

Test Cases:

Input Output
N = 5, arr[] = 1 2 4 5 3
N = 4, arr[] = 2 3 4 1

Solution in C:

#include <stdio.h>

int findMissing(int arr[], int n) {
    int sum = n * (n + 1) / 2;
    for (int i = 0; i < n - 1; i++) {
        sum -= arr[i];
    }
    return sum;
}

int main() {
    int n;
    printf("Enter the value of N: ");
    scanf("%d", &n);

    int arr[n - 1];
    printf("Enter the sequence: ");
    for (int i = 0; i < n - 1; i++) {
        scanf("%d", &arr[i]);
    }

    int missing = findMissing(arr, n);
    printf("Missing number: %d\n", missing);
    return 0;
}

Problem 14: Count Vowels in String

Problem Statement: Write a program to count the number of vowels in a given string. Consider the characters 'a', 'e', 'i', 'o', and 'u' as vowels. The program should be case-insensitive and should return the total count of vowels in the input string.

Test Cases:

Input Output
HelloWorld 3
Wipro 2

Solution in C:

#include <stdio.h>
#include <ctype.h>

int countVowels(char *str) {
    int count = 0;
    while (*str) {
        if (strchr("aeiouAEIOU", *str)) {
            count++;
        }
        str++;
    }
    return count;
}

int main() {
    char str[100];
    printf("Enter a string: ");
    scanf("%s", str);

    printf("Number of vowels: %d\n", countVowels(str));
    return 0;
}

Problem 15: First Non-Repeating Character

Problem Statement: Write a program to find the first non-repeating character in a string. The program should return the first character that does not repeat. If all characters repeat, it should return a message indicating no non-repeating character was found.

Test Cases:

Input Output
swiss w
ccbp b

Solution in C:

#include <stdio.h>
#include <string.h>

char firstNonRepeating(char *str) {
    int freq[256] = {0};

    for (int i = 0; str[i] != '\0'; i++) {
        freq[str[i]]++;
    }

    for (int i = 0; str[i] != '\0'; i++) {
        if (freq[str[i]] == 1) {
            return str[i];
        }
    }
    return '\0'; // No non-repeating character found
}

int main() {
    char str[100];
    printf("Enter a string: ");
    scanf("%s", str);

    char result = firstNonRepeating(str);
    if (result) {
        printf("First non-repeating character: %c\n", result);
    } else {
        printf("No non-repeating character found\n");
    }
    return 0;
}

Top Wipro Coding Questions for 2025

The types of questions asked at Wipro coding assessments can be tricky but mostly contain the logic of these questions. Based on recent trends, here are some of the popular programming concepts you can expect to face:

1. Arrays

2. Strings

3. Linked Lists

4. Stacks and Queues

5. Sorting and Searching

6. Dynamic Programming

7. Recursion

8. Graphs

Wipro Coding Round Tips

To ace the Wipro coding interview questions, here are some essential tips:

1. Understand the Problem Statement

Before jumping into coding, take time to understand the problem statement. Break it down and plan your approach.

2. Practice Regularly

Solving competitive programming regularly is crucial. Use platforms like LeetCode, HackerRank, and Codechef to practice regularly.

3. Plan Your Approach

Try to crack the logic of the question using pen and paper before writing code.

4. Focus on Efficiency

Don't just focus on writing correct code; ensure your solution is efficient in terms of time and space complexity.

5. Debug Your Code

Always debug your code during the interview. Sometimes, minor mistakes can make a solution fail, so practice debugging as well.

Conclusion

In conclusion, Wipro coding questions are a critical part of the selection process and are designed to test your programming and problem-solving abilities. By focusing on mastering coding questions for Wipro, practicing across different difficulty levels, and understanding the concepts in-depth, you can significantly increase your chances of success. Remember to focus on fundamental concepts but also be ready for advanced topics as you progress.

Frequently Asked Questions

1. How can I prepare for the Wipro coding assessment?

To prepare for Wipro coding test questions, practice problems on coding platforms, study data structures and algorithms, and review previous years' Wipro milestone coding questions.

2. Are there different coding questions for different Wipro hiring programs?

Yes, there are specific Wipro coding questions for different hiring programs like Wipro NLTH coding questions, Wipro elite National Talent Hunt coding questions, and Wipro milestone 1 coding questions.


Related Articles


About NxtWave: NxtWave is a leading platform for technical education and career development, helping students and professionals prepare for top IT companies through comprehensive courses and resources.

Contact Information: