Wipro Previous Coding Questions
๐ฅ Wipro Previous Coding Questions with Java & Python Solutions
Welcome to this carefully curated post featuring Wipro Previous Coding Questions asked in real campus placements and technical assessments.
Each problem includes:
โ
A clear and beginner-friendly problem statement
โ
Java and Python code solutions
โ
Sample input and output formats
โ
Easy-to-understand explanation of the logic
Whether you’re preparing for Wiproโs Elite NTH, Turbo hiring, or just practicing for coding rounds โ this guide will help you strengthen your logic and problem-solving skills.
Letโs get started and crack that Wipro coding round! ๐ป๐
โ Problem 1: Lowest Number in the List
๐ Problem Statement
Given a list of integers, find the lowest (minimum) number in the list.
๐ข Input
- First line: An integer n representing the number of elements
- Second line: n space-separated integers
๐งพ Output
- The smallest integer in the list
โ Example
Input:
5
4 9 1 7 3
Output:
1
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int min = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { int val = sc.nextInt(); if (val < min) min = val; } System.out.println(min); } } |
|
1 2 3 |
n = int(input()) arr = list(map(int, input().split())) print(min(arr)) |
๐ Explanation
Loop through all numbers and track the smallest value found.
โ Problem 2: Find Missing Numbers Between Lists
๐ Problem Statement
You are given three lists: A, B, and C.
- B contains all the elements of A except one.
- C contains all the elements of B except one.
Your task is to determine which two numbers are missingโ
- First, find the number that is in A but not in B.
- Second, find the number that is in B but not in C.
๐ข Input
- An integer N
- A list of N integers (A)
- A list of N-1 integers (B)
- A list of N-2 integers (C)
๐งพ Output
- Print the two missing numbers on separate lines.
โ Example
Input:
5
4 5 3 2 1
5 3 2 1
3 1 2
Output:
4
5
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long sumA = 0, sumB = 0, sumC = 0; for (int i = 0; i < n; i++) sumA += sc.nextInt(); for (int i = 0; i < n - 1; i++) sumB += sc.nextInt(); for (int i = 0; i < n - 2; i++) sumC += sc.nextInt(); System.out.println(sumA - sumB); System.out.println(sumB - sumC); } } |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def find_missing_numbers(): n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) missing1 = sum(A) - sum(B) missing2 = sum(B) - sum(C) print(missing1) print(missing2) # Sample Run find_missing_numbers() |
๐ Explanation
Subtract the partial list from the original using set operations.
โ Problem 3: Add Up the Evens
๐ Problem Statement
Given a list of numbers, find the sum of all even numbers in the list.
๐ข Input
- First line: Integer n, the number of elements
- Second line: n space-separated integers
๐งพ Output
- Single integer representing the sum of even numbers
โ Example
Input:
6 1 2 3 4 5 6
Output:
12
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), sum = 0; for (int i = 0; i < n; i++) { int val = sc.nextInt(); if (val % 2 == 0) sum += val; } System.out.println(sum); } } |
|
1 2 3 4 |
n = int(input()) arr = list(map(int, input().split())) even_sum = sum(x for x in arr if x % 2 == 0) print(even_sum) |
๐ Explanation
Use modulo to check if a number is even and then sum it up.
โ Problem 4: Clockwise Angle Between Hour Marks
๐ Problem Statement
Given two numbers representing hour marks on a clock (1โ12), find the clockwise angle between them.
๐ข Input
- Two integers between 1 and 12
๐งพ Output
- The clockwise angle between them in degrees (each hour = 30ยฐ)
โ Example
Input:
3 6
Output:
90
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 |
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(), b = sc.nextInt(); int angle = ((b - a + 12) % 12) * 30; System.out.println(angle); } } |
|
1 2 3 |
a, b = map(int, input().split()) angle = (b - a) % 12 * 30 print(angle) |
๐ Explanation
There are 12 hour marks, and each mark is 30ยฐ. Calculate clockwise difference modulo 12.
โ Problem 5: GCD of Two Numbers
๐ Problem Statement
Find the Greatest Common Divisor (GCD) of two given integers.
๐ข Input
- Two space-separated integers from a single line: a b
๐งพ Output
- A single integer representing their GCD
โ Example
Input:
12 18
Output:
6
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import java.util.Scanner; public class Main { static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(), b = sc.nextInt(); System.out.println(gcd(a, b)); } } |
|
1 2 3 4 |
import math a, b = map(int, input().split()) print(math.gcd(a, b)) |
๐ Explanation
We use the Euclidean algorithm. If b is 0, a is the GCD; otherwise, recurse with b and a % b.
โ Problem 6: GCD of Three Numbers
๐ Problem Statement
Compute the GCD of three integers.
๐ข Input
- Three space-separated integers: a b c
๐งพ Output
- Single integer: GCD of all three numbers
โ Example
Input:
15 30 45
Output:
15
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import java.util.Scanner; public class Main { static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(); int g = gcd(a, b); System.out.println(gcd(g, c)); } } |
|
1 2 3 4 5 |
import math a, b, c = map(int, input().split()) g = math.gcd(a, b) print(math.gcd(g, c)) |
๐ Explanation
Find the GCD of first two numbers, then compute GCD of the result with the third number.
โ Problem 7: Check if a Number is Prime
๐ Problem Statement
Determine whether a given number is a prime number.
๐ข Input
- A single integer n
๐งพ Output
- Print Prime if the number is prime, otherwise print not prime
โ Example
Input:
7
Output:
Prime
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import java.util.Scanner; public class Main { public static boolean isPrime(int n) { if (n <= 1) return false; for (int i = 2; i <= Math.sqrt(n); i++) if (n % i == 0) return false; return true; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); System.out.println(isPrime(n) ? "Prime" : "Not Prime"); } } |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
import math n = int(input()) if n <= 1: print("Not Prime") else: for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: print("Not Prime") break else: print("Prime") |
๐ Explanation
We check for divisibility from 2 to โn. If divisible, itโs not prime.
โ Problem 8: Display Distinct Elements of an Array
๐ Problem Statement
Print all distinct elements from the input list while preserving the order of first appearance.
๐ข Input
- Space-separated integers on a single line
๐งพ Output
- Space-separated integers with duplicates removed
โ Example
Input:
1 2 2 3 4 3 5
Output:
1 2 3 4 5
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] parts = sc.nextLine().split(" "); Set<Integer> seen = new HashSet<>(); for (String p : parts) { int num = Integer.parseInt(p); if (seen.add(num)) { System.out.print(num + " "); } } } } |
|
1 2 3 4 5 6 7 8 |
arr = list(map(int, input().split())) seen = set() res = [] for num in arr: if num not in seen: seen.add(num) res.append(num) print(*res) |
๐ Explanation
Use a set to track seen elements and ensure no duplicates are printed.
โ Problem 9: Remove Vowels from a String
๐ Problem Statement
Remove all vowels (a, e, i, o, u) from the input string.
๐ข Input
- A single line string
๐งพ Output
- The string with vowels removed
โ Example
Input:
ChatGPT is awesome
Output:
ChtGPT s wsm
๐ฃCode
|
1 2 3 4 5 6 7 8 |
import java.util.Scanner; public class Main { public static void main(String[] args) { String input = new Scanner(System.in).nextLine(); System.out.println(input.replaceAll("(?i)[aeiou]", "")); } } |
|
1 2 3 |
s = input() vowels = "aeiouAEIOU" print(''.join([c for c in s if c not in vowels])) |
๐ Explanation
We filter out vowels using list comprehension (Python) or regex (Java).
โ Problem 10: Sum of All Odd Digits in a Number
๐ Problem Statement
Find the sum of all odd digits in the given number.
๐ข Input
- A single integer
๐งพ Output
- Sum of all odd digits
โ Example
Input:
53821
Output:
17
(5 + 3 + 1 + 7)
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import java.util.Scanner; public class Main { public static void main(String[] args) { String n = new Scanner(System.in).nextLine(); int sum = 0; for (char ch : n.toCharArray()) { int digit = ch - '0'; if (digit % 2 != 0) sum += digit; } System.out.println(sum); } } |
|
1 2 3 |
n = input() odd_sum = sum(int(d) for d in n if int(d) % 2 != 0) print(odd_sum) |
๐ Explanation
Traverse each digit and check if itโs odd using % 2 != 0, then add to the total.
โ Problem 11: Transpose of a Matrix
๐ Problem Statement
Find the transpose of the given matrix.
๐ข Input
- First line: Two integers r c (rows and columns)
- Next r lines: Each line has c integers
๐งพ Output
- The transposed matrix (columns become rows)
โ Example
Input:
2 3
1 2 3
4 5 6
Output:
1 4
2 5
3 6
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r = sc.nextInt(), c = sc.nextInt(); int[][] mat = new int[r][c]; for (int i = 0; i < r; i++) for (int j = 0; j < c; j++) mat[i][j] = sc.nextInt(); for (int i = 0; i < c; i++) { for (int j = 0; j < r; j++) System.out.print(mat[j][i] + " "); System.out.println(); } } } |
|
1 2 3 4 5 |
r, c = map(int, input().split()) matrix = [list(map(int, input().split())) for _ in range(r)] transpose = [[matrix[i][j] for i in range(r)] for j in range(c)] for row in transpose: print(*row) |
๐ Explanation
Transpose means flipping rows to columns. We switch matrix[i][j] to matrix[j][i].
โ Problem 12: Matrix Multiplication
๐ Problem Statement
Multiply two matrices A and B and print the result.
๐ข Input
- First line: Two integers r1 c1 (rows and columns of A)
- Next r1 lines: c1 integers each (Matrix A)
- Then: Two integers r2 c2 (rows and columns of B)
- Next r2 lines: c2 integers each (Matrix B)
๐งพ Output
- Resultant matrix after multiplying A and B
โ Example
Input:
2 2
1 2
3 4
2 2
5 6
7 8
Output:
19 22
43 50
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r1 = sc.nextInt(), c1 = sc.nextInt(); int[][] A = new int[r1][c1]; for (int i = 0; i < r1; i++) for (int j = 0; j < c1; j++) A[i][j] = sc.nextInt(); int r2 = sc.nextInt(), c2 = sc.nextInt(); int[][] B = new int[r2][c2]; for (int i = 0; i < r2; i++) for (int j = 0; j < c2; j++) B[i][j] = sc.nextInt(); if (c1 != r2) { System.out.println("Cannot multiply"); return; } int[][] C = new int[r1][c2]; for (int i = 0; i < r1; i++) for (int j = 0; j < c2; j++) for (int k = 0; k < c1; k++) C[i][j] += A[i][k] * B[k][j]; for (int[] row : C) { for (int val : row) System.out.print(val + " "); System.out.println(); } } } |
|
1 2 3 4 5 6 7 8 9 10 11 |
r1, c1 = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(r1)] r2, c2 = map(int, input().split()) B = [list(map(int, input().split())) for _ in range(r2)] if c1 != r2: print("Cannot multiply") else: result = [[sum(A[i][k] * B[k][j] for k in range(c1)) for j in range(c2)] for i in range(r1)] for row in result: print(*row) |
๐ Explanation
Standard matrix multiplication: A[i][k] * B[k][j] for all valid k, summed over.
โ Problem 13: Check Balance of Parentheses
๐ Problem Statement
Check if the parentheses in a string are balanced (( ), { }, [ ]).
๐ข Input
- A string containing brackets
๐งพ Output
- Print Balanced or Not Balanced
โ Example
Input:
({[]})
Output:
Balanced
๐ฃCode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import java.util.*; public class Main { public static boolean isBalanced(String s) { Stack<Character> stack = new Stack<>(); Map<Character, Character> pairs = Map.of(')', '(', '}', '{', ']', '['); for (char ch : s.toCharArray()) { if ("({[".indexOf(ch) >= 0) stack.push(ch); else if (")}]".indexOf(ch) >= 0) { if (stack.isEmpty() || stack.pop() != pairs.get(ch)) return false; } } return stack.isEmpty(); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(isBalanced(sc.nextLine()) ? "Balanced" : "Not Balanced"); } } |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
def is_balanced(expr): stack = [] pair = {')': '(', ']': '[', '}': '{'} for ch in expr: if ch in '([{': stack.append(ch) elif ch in ')]}': if not stack or stack[-1] != pair[ch]: return False stack.pop() return not stack print("Balanced" if is_balanced(input()) else "Not Balanced") |
๐ Explanation
Use a stack to match opening and closing brackets. Ensure stack is empty at end.
๐จ Wipro Overview!
Curious about how Wipro’s selection process works, the rounds involved, and other key details? Donโt miss this complete breakdown:
๐ https://nextgenkodinghub.in/wipro-overview/
Wishing you the best of luck! ๐ผโจ

