Autocoder

Wipro Coding Round Questions with Solutions

Last updated 2026-11-19

Wipro's coding questions are commonly reported to be at the easier end: strings, arrays and number logic where correctness and edge cases matter more than advanced algorithms. These ten problems have worked Python and Java solutions.

See Wipro interview questions for the spoken rounds and how to crack the DSA coding round for general approach.

LevelEasy to medium
LanguagesPython and Java shown
TopicsStrings, arrays, matrices, number logic

What the Wipro coding section looks like

Prep sources describe the coding component of Wipro's online assessment as the easier end of the scale: one or two problems on strings, arrays and number logic, often in the same sitting as aptitude and verbal sections (see Weekday's off-campus guide in the sources). Because the bar is correctness on standard cases rather than clever optimisation, speed and careful edge handling decide results. The ten problems here follow that style and are practice in the spirit of those topics, not a real paper.

Tips for easy-level rounds

Wipro Coding Round Questions with Solutions: questions with worked answers

  1. 1

    Check whether a string is a palindrome, ignoring case and non-alphanumerics

    easy

    Use two pointers from both ends, skipping characters that are not letters or digits, comparing in lower case. Complexity: O(n) time, O(1) space. Common mistakes: building a reversed copy when memory is limited and forgetting to skip punctuation, so 'A man, a plan' fails.

    python
    def is_pal(s):
        i, j = 0, len(s) - 1
        while i < j:
            if not s[i].isalnum(): i += 1
            elif not s[j].isalnum(): j -= 1
            elif s[i].lower() != s[j].lower(): return False
            else: i += 1; j -= 1
        return True
    print(is_pal("A man, a plan, a canal: Panama"))  # True
    java
    class Solution {
        static boolean isPal(String s) {
            int i = 0, j = s.length() - 1;
            while (i < j) {
                char a = s.charAt(i), b = s.charAt(j);
                if (!Character.isLetterOrDigit(a)) i++;
                else if (!Character.isLetterOrDigit(b)) j--;
                else if (Character.toLowerCase(a) != Character.toLowerCase(b)) return false;
                else { i++; j--; }
            }
            return true;
        }
    }
  2. 2

    Reverse the words in a sentence

    easy

    Split on whitespace, reverse the list of words, join with single spaces. Splitting with no argument in Python (or split on one or more spaces in Java) handles extra spaces. Complexity: O(n) time, O(n) space. Common mistakes: splitting on a single space (keeps empty strings) and reversing characters instead of words.

    python
    def reverse_words(s):
        return ' '.join(reversed(s.split()))
    print(reverse_words("  hello   world  "))  # world hello
    java
    class Solution {
        static String reverseWords(String s) {
            String[] w = s.trim().split("\\s+");
            StringBuilder sb = new StringBuilder();
            for (int i = w.length - 1; i >= 0; i--) {
                sb.append(w[i]);
                if (i > 0) sb.append(' ');
            }
            return sb.toString();
        }
    }
  3. 3

    Sort an array of 0s, 1s and 2s in one pass

    medium

    Dutch national flag: keep low, mid and high pointers. Swap 0s to the front, 2s to the back, move past 1s. Do not advance mid after swapping with high, since the swapped-in value is unchecked. Complexity: O(n) time, O(1) space. Common mistakes: incrementing mid after swapping with high and using counting sort when the question asks for a single pass in place.

    python
    def sort012(a):
        lo, mid, hi = 0, 0, len(a) - 1
        while mid <= hi:
            if a[mid] == 0:
                a[lo], a[mid] = a[mid], a[lo]; lo += 1; mid += 1
            elif a[mid] == 1: mid += 1
            else:
                a[mid], a[hi] = a[hi], a[mid]; hi -= 1
        return a
    print(sort012([2, 0, 1, 2, 0, 1]))  # [0, 0, 1, 1, 2, 2]
    java
    class Solution {
        static void sort012(int[] a) {
            int lo = 0, mid = 0, hi = a.length - 1;
            while (mid <= hi) {
                if (a[mid] == 0) { int t = a[lo]; a[lo++] = a[mid]; a[mid++] = t; }
                else if (a[mid] == 1) mid++;
                else { int t = a[mid]; a[mid] = a[hi]; a[hi--] = t; }
            }
        }
    }
  4. 4

    Merge two sorted arrays

    easy

    Two pointers, always taking the smaller head, then append whichever array has leftovers. Complexity: O(m + n) time, O(m + n) space. Common mistakes: concatenating and re-sorting (O((m + n) log(m + n))) and forgetting the leftover tail.

    python
    def merge(a, b):
        i = j = 0; out = []
        while i < len(a) and j < len(b):
            if a[i] <= b[j]: out.append(a[i]); i += 1
            else: out.append(b[j]); j += 1
        return out + a[i:] + b[j:]
    print(merge([1, 3, 5], [2, 4, 6, 8]))  # [1, 2, 3, 4, 5, 6, 8]
    java
    class Solution {
        static int[] merge(int[] a, int[] b) {
            int[] out = new int[a.length + b.length];
            int i = 0, j = 0, k = 0;
            while (i < a.length && j < b.length) out[k++] = a[i] <= b[j] ? a[i++] : b[j++];
            while (i < a.length) out[k++] = a[i++];
            while (j < b.length) out[k++] = b[j++];
            return out;
        }
    }
  5. 5

    First non-repeating character

    easy

    Count frequencies in one pass, then scan the string again and return the first character with count 1. Complexity: O(n) time, O(k) space. Common mistakes: scanning the count map instead of the string (loses order in some languages) and not handling the all-repeating case.

    python
    from collections import Counter
    def first_unique(s):
        c = Counter(s)
        for ch in s:
            if c[ch] == 1: return ch
        return None
    print(first_unique("swiss"))  # w
    java
    class Solution {
        static char firstUnique(String s) {
            int[] c = new int[256];
            for (char ch : s.toCharArray()) c[ch]++;
            for (char ch : s.toCharArray()) if (c[ch] == 1) return ch;
            return '\0';
        }
    }
  6. 6

    Check whether two strings are anagrams

    easy

    Strip case and spaces if required, then compare sorted characters or character counts. Counting is linear. Complexity: O(n) time, O(1) space for a fixed alphabet. Common mistakes: comparing lengths only after normalising, and treating different case as different letters when the statement says otherwise.

    python
    from collections import Counter
    def anagram(a, b):
        f = lambda s: Counter(s.replace(' ', '').lower())
        return f(a) == f(b)
    print(anagram("Listen", "Silent"), anagram("abc", "abd"))  # True False
    java
    class Solution {
        static boolean anagram(String a, String b) {
            int[] c = new int[26];
            for (char ch : a.toLowerCase().toCharArray()) if (ch >= 'a' && ch <= 'z') c[ch - 'a']++;
            for (char ch : b.toLowerCase().toCharArray()) if (ch >= 'a' && ch <= 'z') c[ch - 'a']--;
            for (int x : c) if (x != 0) return false;
            return true;
        }
    }
  7. 7

    Print the first N Fibonacci numbers and test for primes up to N

    easy

    Two small loops. Fibonacci: iterate with two variables. Primes: sieve of Eratosthenes marks multiples starting at p squared. Complexity: Fibonacci O(N); sieve O(N log log N) time, O(N) space. Common mistakes: trial dividing every number up to N (slow) and starting the sieve from 2p instead of p squared, which is correct but wasteful.

    python
    def fib(n):
        a, b, out = 0, 1, []
        for _ in range(n): out.append(a); a, b = b, a + b
        return out
    def primes(n):
        s = [True] * (n + 1); s[0:2] = [False, False]
        for p in range(2, int(n ** 0.5) + 1):
            if s[p]:
                for m in range(p * p, n + 1, p): s[m] = False
        return [i for i, v in enumerate(s) if v]
    print(fib(8), primes(30))
    java
    import java.util.*;
    class Solution {
        static List<Integer> primes(int n) {
            boolean[] comp = new boolean[n + 1];
            List<Integer> out = new ArrayList<>();
            for (int p = 2; p <= n; p++) {
                if (comp[p]) continue;
                out.add(p);
                for (long m = (long) p * p; m <= n; m += p) comp[(int) m] = true;
            }
            return out;
        }
    }
  8. 8

    Transpose a matrix and rotate it 90 degrees clockwise

    medium

    Transpose in place (swap a[i][j] with a[j][i] for j > i), then reverse each row. That equals a 90-degree clockwise rotation for a square matrix. Complexity: O(n squared) time, O(1) space. Common mistakes: swapping across the whole matrix so every pair is swapped twice (a no-op) and reversing columns instead of rows.

    python
    def rotate(m):
        n = len(m)
        for i in range(n):
            for j in range(i + 1, n):
                m[i][j], m[j][i] = m[j][i], m[i][j]
        for row in m: row.reverse()
        return m
    print(rotate([[1, 2], [3, 4]]))  # [[3, 1], [4, 2]]
    java
    class Solution {
        static void rotate(int[][] m) {
            int n = m.length;
            for (int i = 0; i < n; i++)
                for (int j = i + 1; j < n; j++) { int t = m[i][j]; m[i][j] = m[j][i]; m[j][i] = t; }
            for (int[] row : m)
                for (int i = 0, j = n - 1; i < j; i++, j--) { int t = row[i]; row[i] = row[j]; row[j] = t; }
        }
    }
  9. 9

    Find the missing number in 1..N

    easy

    The sum of 1..N is N(N+1)/2; subtract the array sum. XOR of all indices and values also works and cannot overflow. Complexity: O(n) time, O(1) space. Common mistakes: using int for the sum when N is large and assuming the array is sorted.

    python
    def missing(a):
        n = len(a) + 1
        return n * (n + 1) // 2 - sum(a)
    print(missing([1, 2, 4, 5]))  # 3
    java
    class Solution {
        static int missing(int[] a) {
            int x = a.length + 1;
            for (int i = 0; i < a.length; i++) x ^= (i + 1) ^ a[i];
            return x;
        }
    }
  10. 10

    Convert a decimal number to binary without built-ins

    easy

    Repeatedly divide by 2 and collect remainders, then reverse them. Handle 0 specially, since the loop never runs. Complexity: O(log n) time, O(log n) space. Common mistakes: returning an empty string for 0 and forgetting to reverse the remainders.

    python
    def to_binary(n):
        if n == 0: return "0"
        bits = []
        while n: bits.append(str(n % 2)); n //= 2
        return ''.join(reversed(bits))
    print(to_binary(10))  # 1010
    java
    class Solution {
        static String toBinary(int n) {
            if (n == 0) return "0";
            StringBuilder sb = new StringBuilder();
            while (n > 0) { sb.append(n % 2); n /= 2; }
            return sb.reverse().toString();
        }
    }

Frequently asked questions

How many coding questions does Wipro ask?

It varies by programme and cycle; check your own test instructions.

Which language should I choose?

The one you can debug fastest; Python and Java are both standard.

Is the Wipro coding test easy?

It is commonly considered easier than product-company tests, but time pressure with other sections makes it tight.

Where do I find Wipro's real notices?

Wipro's careers page and Wipro hiring.

Sources

Related guides

More in Company Interview Questions

See all in this section