Infosys SP and DSE Previous Year Coding Questions (2025 Guide)
Landing a role at Infosys as a Specialist Programmer (SP) or Digital Specialist Engineer (DSE) is a significant career milestone. With competitive packages and excellent growth opportunities, these positions attract thousands of applicants each year. The coding round often becomes the make-or-break factor in your selection journey.
This guide provides everything you need to ace the coding interviews, including real previous year questions, detailed preparation strategies, and insider tips from successful candidates.
Whether you're preparing for HackWithInfy, off-campus hiring, or internal Infosys SP/DSE interviews — this guide will help you stand out.
Why Choose Infosys SP/DSE?
Infosys remains one of India's top IT employers, offering:
- Global exposure with projects across 50+ countries
- Cutting-edge technology work in AI, Cloud, and Digital transformation
- Career progression with clear growth paths and certifications
- Work-life balance with flexible working arrangements
- Learning opportunities through Infosys Mysore and online platforms
SP vs DSE: Complete Comparison
Criteria | SP (Specialist Programmer) | DSE (Digital Specialist Engineer) |
---|---|---|
CTC | ~₹9 LPA | ~₹6.25 LPA |
Experience Required | 0–2 years | 0–1 years |
Role Focus | Full-stack, AI, Backend Systems | Frontend, Testing, Support Development |
Technologies | Java, Python, .NET, Cloud, AI/ML | React, Angular, Testing Frameworks |
Difficulty Level | High | Medium |
Growth Potential | Technology Specialist → Architect | Digital Engineer → Lead Developer |
Coding Round: What to Expect
Format & Structure
- Duration: 60-90 minutes
- Platform: Infosys proprietary platform or HackerRank
- Languages: C++, Java, Python (choose your strongest)
- Environment: Browser-based IDE with basic debugging tools
Question Distribution
- SP Role: 2 challenging problems (typically one algorithmic, one system design oriented)
- DSE Role: 1-2 medium difficulty problems focusing on logical thinking
Evaluation Criteria
- Correctness: All test cases must pass
- Code Quality: Clean, readable, and well-commented code
- Efficiency: Optimal time and space complexity
- Edge Cases: Handling boundary conditions properly
Preparation Strategy
Phase 1: Foundation Building (2-3 weeks)
- Master basic data structures: Arrays, Strings, Linked Lists, Stacks, Queues
- Learn essential algorithms: Sorting, Searching, Two Pointers, Sliding Window
- Practice 10-15 easy problems daily on LeetCode/GeeksforGeeks
Phase 2: Intermediate Skills (3-4 weeks)
- Advanced data structures: Trees, Graphs, Hash Maps, Heaps
- Dynamic Programming basics and common patterns
- Solve 5-8 medium problems daily with time constraints
Phase 3: Mock Tests & Optimization (1-2 weeks)
- Take timed mock tests simulating actual interview conditions
- Focus on code optimization and reducing time complexity
- Practice explaining your approach clearly
Give free mock test from here - Link
Infosys SP and DSE Previous Year Coding Questions
These questions are compiled from real interview experiences and assessment patterns. Practice these to understand the exact difficulty level and question types.
Gift Box Packing Problem
Difficulty: Medium-Hard | Frequency: High | Topic: Dynamic Programming
Problem: You have N gifts of different types. Pack them into exactly K boxes (consecutive subarrays) such that each box's value equals the number of distinct gift types in it. Maximize the total value across all boxes.
Example:
Input: N=6, K=3, gifts=[1,1,2,2,3,3]
Output: 6 (boxes: [1,1]=1, [2,2]=1, [3,3]=1, total=3 is not optimal)
Better: [1,1,2]=2, [2]=1, [3,3]=1, total=4
Optimal: [1]=1, [1,2,2]=2, [3,3]=1, total=4
Input Format:
N K
A[1] A[2] ... A[N]
Output Format:
Maximum possible total value
💡Solution Approach: Use DP with sliding window technique and hash map to track distinct elements efficiently. For each position, try all possible box endings and memoize results.
Array Minimization Problem
Difficulty: Medium | Frequency: High | Topic: Greedy Algorithm
Problem: Given an array, you can perform two operations:
- Subtract 1 from all elements in subarray [L,R] with cost X
- Set any element A[i] to 0 with cost Y
Find minimum cost to make all elements zero.
Example:
Input: N=3, X=2, Y=3, A=[4,2,1]
Output: 8
Explanation: Operation 1 on [1,3] twice (cost=4), then operation 1 on [1,2] twice (cost=4)
Total cost = 8
Input Format:
N X Y
A[1] A[2] ... A[N]
Output Format:
Minimum total cost
💡 Solution Approach: For each element, compare cost of reducing it to 0 via subarray operations vs direct assignment. Use prefix sums to optimize range operations.
Terrain Transformation
Difficulty: Hard | Frequency: Medium | Topic: Binary Search + Greedy
Problem: Transform terrain heights to strictly decreasing sequence. Each day, you can reduce any segment's height by any power of 2 (1, 2, 4, 8, ...). Find minimum days required.
Example:
Input: N=4, heights=[8,6,4,2]
Output: 0 (already decreasing)
Input: N=3, heights=[5,5,5]
Output: 2
Day 1: [5,4,4] (reduce middle by 1)
Day 2: [5,4,3] (reduce last by 1)
Input Format:
N
L[1] L[2] ... L[N]
Output Format:
Minimum days required
💡 Solution Approach: Binary search on answer. For each day count, check if it's possible to make sequence decreasing using greedy allocation of reduction operations.
Same Digit Base Conversion
Difficulty: Medium | Frequency: Medium | Topic: Number Theory
Problem: Find the smallest base K such that decimal number M, when converted to base K, has all identical digits.
Example:
Input: M=15
Output: 4
Explanation: 15 in base 4 = 33 (all digits same)
Input: M=7
Output: 6
Explanation: 7 in base 6 = 11
Input Format:
M
Output Format:
Smallest valid base K
💡 Solution Approach: For each possible base from 2 to M, convert M to that base and check if all digits are identical. Optimize by noting that for base b, M should be of form d×(b^n-1)/(b-1).
Maximum Vacation Days
Difficulty: Easy-Medium | Frequency: High | Topic: Array Processing
Problem: Andy has N days and M obligation days when he cannot take vacation. Find the maximum number of consecutive vacation days possible.
Example:
Input: N=10, M=3, obligations=[2,5,8]
Output: 4
Explanation: Days 1-1 (1 day), 3-4 (2 days), 6-7 (2 days), 9-10 (2 days)
Maximum consecutive = 2... wait, actually 9-10-11-12... no, N=10
Actually: 6-7 and 9-10, so max consecutive is 2
Better: if obligations are [2,5,8] in days 1-10
Gaps: 1, 3-4, 6-7, 9-10. Max gap = 2
Input Format:
N M
day[1] day[2] ... day[M]
Output Format:
Maximum consecutive vacation days
💡 Solution Approach: Sort obligation days, find maximum gap between consecutive obligations, also consider gaps at beginning and end.
Conditional Longest Increasing Subsequence
Difficulty: Hard | Frequency: Low | Topic: Dynamic Programming
Problem: Find length of LIS where adjacent elements satisfy: A[i] OP A[i+1] == target, where OP is AND, OR, or XOR.
Example:
Input: N=4, A=[1,3,2,4], OP=AND, target=0
Output: 3
Explanation: Subsequence [1,3,4] where 1&3=1≠0, 3&4=0=target...
Need to check adjacent pairs in LIS
Input Format:
N
A[1] A[2] ... A[N]
operation_type target_value
Output Format:
Length of valid LIS
💡 Solution Approach: Modify standard LIS DP to include bitwise condition checking between adjacent elements in the subsequence.
Element Frequency Analysis
Difficulty: Easy | Frequency: Very High | Topic: Hash Map
Problem: Count total repeated elements and total non-repeated elements in an array.
Example:
Input: N=6, A=[1,2,2,3,3,3]
Output: 2 1
Explanation: Elements 2,3 are repeated (count=2), element 1 is non-repeated (count=1)
Input Format:
N
A[1] A[2] ... A[N]
Output Format:
repeated_count non_repeated_count
💡 Solution Approach: Use frequency map to count occurrences, then categorize elements based on frequency > 1 or == 1.
First Non-Repeating Character
Difficulty: Easy | Frequency: Very High | Topic: String Processing
Problem: Find the first character that appears exactly once in the string.
Example:
Input: "programming"
Output: 'p'
Explanation: 'p' appears once and comes first among non-repeating chars
Input: "aabbcc"
Output: 'None'
Input Format:
string S
Output Format:
first_non_repeating_character or 'None'
💡 Solution Approach: Two-pass solution: count frequencies, then find first character with frequency 1. Or use ordered dictionary for single pass.
Reverse Linked List
Difficulty: Easy-Medium | Frequency: Very High | Topic: Linked Lists
Problem: Reverse a singly linked list iteratively or recursively.
Example:
Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL
Input Format:
N
node[1] node[2] ... node[N]
Output Format:
Reversed linked list
💡 Solution Approach: Iterative: Use three pointers (prev, curr, next). Recursive: Reverse rest of list, then adjust pointers.
Add Two Numbers (Linked Lists)
Difficulty: Medium | Frequency: High | Topic: Linked Lists + Math
Problem: Add two numbers represented as linked lists (digits in reverse order).
Example:
Input: L1: 2->4->3 (represents 342)
L2: 5->6->4 (represents 465)
Output: 7->0->8 (represents 807)
Input Format:
Two linked lists representing numbers
Output Format:
Sum as linked list
💡 Solution Approach: Simulate elementary addition with carry. Handle different lengths and final carry carefully.
Maximum Subarray Sum
Difficulty: Medium | Frequency: Very High | Topic: Dynamic Programming
Problem: Find the maximum sum of any contiguous subarray.
Example:
Input: [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6
Input Format:
N
A[1] A[2] ... A[N]
Output Format:
Maximum subarray sum
💡 Solution Approach: Kadane's Algorithm - track current sum and maximum sum seen so far.
First Occurrence in Sorted Array
Difficulty: Easy-Medium | Frequency: High | Topic: Binary Search
Problem: Find the first occurrence of target element in a sorted array.
Example:
Input: A=[1,2,2,2,3,4,5], target=2
Output: 1 (0-indexed)
Input: A=[1,3,5,7], target=4
Output: -1
Input Format:
Sorted array A, target T
Output Format:
Index of first occurrence of T or -1
💡 Solution Approach: Modified binary search - when target found, continue searching in left half to find first occurrence.
Goal Tracker
Difficulty: Easy | Frequency: Medium | Topic: Basic Math
Problem: Calculate average steps per day needed to reach goal.
Example:
Input: S=1000 (goal), D=300 (done), N=7 (days remaining)
Output: 100 (rounded average)
Explanation: (1000-300)/7 = 100 steps per day
Input Format:
S D N
Output Format:
Average steps per day (rounded)
💡 Solution Approach: Simple arithmetic - (goal - done) / days_remaining, with proper rounding.
Octal to Binary Conversion
Difficulty: Easy | Frequency: Medium | Topic: Number System
Problem: Convert octal number to binary representation.
Example:
Input: 17 (octal)
Output: 1111 (binary)
Explanation: 17₈ = 1×8¹ + 7×8⁰ = 15₁₀ = 1111₂
Input: 25 (octal)
Output: 10101 (binary)
Input Format:
Octal number
Output Format:
Binary string
💡 Solution Approach: Convert octal → decimal → binary, or directly convert each octal digit to 3-bit binary.
Swap Two Arrays
Difficulty: Easy | Frequency: Low | Topic: Array Manipulation
Problem: Swap all elements between two arrays A and B.
Example:
Input: N=3, A=[1,2,3], B=[4,5,6]
Output: A=[4,5,6], B=[1,2,3]
Input Format:
N
A[1] A[2] ... A[N]
B[1] B[2] ... B[N]
Output Format:
Swapped arrays A and B
💡 Solution Approach: Simple element-wise swapping using temporary variable or XOR operation.
0/1 Knapsack Problem
Difficulty: Medium-Hard | Frequency: Medium | Topic: Dynamic Programming
Problem: Given items with weights and values, maximize value within weight capacity W.
Example:
Input: N=3, W=4, weights=[4,5,1], values=[1,2,3]
Output: 3
Explanation: Take item 3 (weight=1, value=3)
Input Format:
N W
weights[1] weights[2] ... weights[N]
values[1] values[2] ... values[N]
Output Format:
Maximum achievable value
💡 Solution Approach: DP table dp[i][w] = maximum value using first i items with weight limit w.
Tower of Hanoi
Difficulty: Medium | Frequency: Low | Topic: Recursion
Problem: Find sequence of moves to transfer N disks from source to destination rod.
Example:
Input: N=2
Output:
Move disk 1 from A to B
Move disk 2 from A to C
Move disk 1 from B to C
Input Format:
N
Output Format:
Sequence of moves
💡 Solution Approach: Recursive solution - move n-1 disks to auxiliary, move largest to destination, move n-1 from auxiliary to destination.
Factorial Calculation
Difficulty: Easy | Frequency: Medium | Topic: Basic Programming
Problem: Calculate factorial of given number N.
Example:
Input: N=5
Output: 120
Explanation: 5! = 5×4×3×2×1 = 120
Input: N=0
Output: 1
Input Format:
N
Output Format:
N!
💡 Solution Approach: Iterative multiplication or recursive approach. Handle edge case N=0.
Bitwise AND of Range
Difficulty: Medium-Hard | Frequency: Low | Topic: Bit Manipulation
Problem: Find bitwise AND of all numbers in range [L, R].
Example:
Input: L=5, R=7
Output: 4
Explanation: 5 & 6 & 7 = 101 & 110 & 111 = 100 = 4
Input: L=1, R=3
Output: 0
Input Format:
L R
Output Format:
Bitwise AND of all numbers from L to R
💡 Solution Approach: Key insight - find common prefix of L and R in binary. Shift both right until they become equal.
Array and Bit Manipulation
Difficulty: Medium | Frequency: Medium | Topic: Bit Operations
Problem: For each element in array, find the smallest power of 2 greater than or equal to it.
Example:
Input: A=[3, 7, 1, 10]
Output: [4, 8, 1, 16]
Explanation:
- For 3: smallest power of 2 ≥ 3 is 4
- For 7: smallest power of 2 ≥ 7 is 8
- For 1: smallest power of 2 ≥ 1 is 1
- For 10: smallest power of 2 ≥ 10 is 16
Input Format:
Array A[1 to N]
Output Format:
Array of smallest powers of 2
💡 Solution Approach: For each number, if it's already a power of 2, return it. Otherwise, find the position of MSB and return 2^(position+1).
Recommended Practice Resources
Online Platforms
- Lets Code: Roadmaps, Interview questions , PYQs & Free mock text
- LeetCode: Focus on Medium problems, company-specific questions
- GeeksforGeeks: Excellent for understanding concepts with examples
- HackerRank: Similar interface to actual test environment
- CodeChef: Good for mathematical problems
Books
- "Cracking the Coding Interview" by Gayle McDowell
- "Elements of Programming Interviews" by Aziz, Lee, and Prakash
- "Introduction to Algorithms" by CLRS (for deeper understanding)
YouTube Channels
- Abdul Bari (Algorithms)
- Tushar Roy (Dynamic Programming)
- Back To Back SWE (Problem-solving techniques)
Week Before Interview
- Take 2-3 full mock tests
- Review your most challenging solved problems
- Practice explaining solutions out loud
- Get adequate sleep and stay calm
Day of Interview
- Start with easier problem to build confidence
- Think out loud during problem-solving
- Don't panic if stuck - try different approaches
- Submit working solution even if not fully optimized
Conclusion
With dedicated preparation using this guide, you're well-equipped to crack the Infosys SP/DSE coding round. Remember, consistency beats intensity - regular practice with gradual difficulty increase is more effective than last-minute cramming.
Best of luck with your Infosys journey!
Keep coding, keep growing!
Join our Telegram group for more updates