DXC Technology coding round questions
Last updated 2026-11-19
DXC Technology builds and runs IT services for large clients, much of it around long-lived systems: batch jobs, fixed-format files, support queues and applications that have been in production for decades. Commonly shared accounts of its fresher tests describe basic to medium coding plus technical multiple-choice questions, so this set is built from that world. You will parse a column-aligned record, tally log lines, work through recursion, and query a small ticket database.
All twelve are original practice problems, not a copy of any past test. For the interview rounds, read DXC Technology interview questions, and see the off-campus drive guide for how these drives are usually approached.
| Style (commonly reported) | Basic to medium coding, plus technical MCQs |
|---|---|
| Difficulty here | Easy to medium |
| Languages | Python, Java and SQL shown |
Reading the problem as an operations engineer would
Services work is judged by whether the job runs unattended and produces the right output every night. That mindset translates into test habits: parse input defensively, count things exactly, and prefer the clear loop over the clever one. A solution that is easy to read is easier to fix at three in the morning, and graders reading your code can tell.
The recursion questions are there because tests of this kind like to check that you understand a call stack: what the base case is, how the problem shrinks, and what the result is on the way back up.
How to practise the set
- Do the three SQL questions first. They are short and a common source of quick marks.
- For each recursion problem, write the base case on its own line before anything else.
- Trace one small input by hand on paper, then run your code and compare the two.
Hiring status
No sourced DXC statement on fresher numbers or dates is held on this site, so none are quoted. Check DXC Technology's own careers site for current openings and test details.
DXC Technology coding round questions: questions with worked answers
1 Parse a fixed-width customer record: id in columns 1 to 6, name in 7 to 26, balance in cents in 27 to 36.
easySlice the line at the column boundaries and convert each piece: int for the id, strip the padding from the name, and int for the cents balance. Keep the balance as integer cents and only convert to rupees when printing. O(1) per record. Common mistakes: off-by-one slices because columns are numbered from 1 while indexes start at 0, and forgetting to strip the right-padding on the name.
pythondef parse_record(line): return { 'id': int(line[0:6]), 'name': line[6:26].strip(), 'balance_cents': int(line[26:36]), }javaclass Record { final int id; final String name; final long balanceCents; Record(int id, String name, long balanceCents) { this.id = id; this.name = name; this.balanceCents = balanceCents; } static Record parse(String line) { return new Record(Integer.parseInt(line.substring(0, 6).trim()), line.substring(6, 26).trim(), Long.parseLong(line.substring(26, 36).trim())); } }2 Count how many log lines there are at each level (INFO, WARN, ERROR) when each line looks like: date time LEVEL message.
easySplit each line on whitespace and read the third token as the level. Count only the levels you recognise, so malformed lines are skipped instead of crashing the job. O(total characters). Common mistakes: searching for the word ERROR anywhere in the line, which also matches messages that merely mention it, and crashing on blank lines.
pythondef count_levels(lines): counts = {'INFO': 0, 'WARN': 0, 'ERROR': 0} for line in lines: parts = line.split() if len(parts) >= 3 and parts[2] in counts: counts[parts[2]] += 1 return countsjavaimport java.util.*; class Logs { static Map<String, Integer> countLevels(List<String> lines) { Map<String, Integer> counts = new LinkedHashMap<>(); counts.put("INFO", 0); counts.put("WARN", 0); counts.put("ERROR", 0); for (String line : lines) { String[] p = line.trim().split("\\s+"); if (p.length >= 3 && counts.containsKey(p[2])) counts.merge(p[2], 1, Integer::sum); } return counts; } }3 How many trailing zeros does n factorial have?
mediumEach trailing zero comes from a factor pair of 2 and 5, and there are always more 2s than 5s, so count the 5s. That is n/5 + n/25 + n/125 and so on, using integer division. O(log n) time. Common mistakes: computing the factorial itself, which overflows quickly, and counting only n/5 and missing the extra 5s in multiples of 25.
pythondef trailing_zeros(n): count = 0 while n: n //= 5 count += n return countjavaclass Factorial { static long trailingZeros(long n) { long count = 0; while (n > 0) { n /= 5; count += n; } return count; } }4 Write recursive functions for the GCD and the LCM of two positive integers.
easyEuclid's rule: gcd(a, b) is a when b is zero, otherwise gcd(b, a mod b). The LCM follows as a / gcd * b, dividing first to avoid overflow. The recursion depth is O(log min(a, b)). Common mistakes: forgetting the base case, and computing a * b / gcd, which can overflow a 32-bit integer.
pythondef gcd(a, b): return a if b == 0 else gcd(b, a % b) def lcm(a, b): return a // gcd(a, b) * bjavaclass Euclid { static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } static long lcm(long a, long b) { return a / gcd(a, b) * b; } }5 List the moves that solve the Tower of Hanoi for n discs.
mediumMove the top n-1 discs to the spare peg, move the largest disc to the target, then move the n-1 discs from the spare onto the target. That produces 2^n - 1 moves, so time and output are O(2^n), and recursion depth is n. Common mistakes: swapping the roles of the target and spare pegs in one of the recursive calls, and confusing the move count with the depth.
pythondef hanoi(n, source, target, spare): if n == 0: return [] return (hanoi(n - 1, source, spare, target) + [(source, target)] + hanoi(n - 1, spare, target, source))javaimport java.util.*; class Hanoi { static void solve(int n, char from, char to, char via, List<String> moves) { if (n == 0) return; solve(n - 1, from, via, to, moves); moves.add(from + "->" + to); solve(n - 1, via, to, from, moves); } }6 Generate every subset of a list of distinct items.
mediumDecide for each item in turn whether to include it. The recursion branches into 'skip' and 'take', and at the end of the list the chosen items form one subset. There are 2^n subsets, so O(n * 2^n) time and output. Common mistakes: appending the working list itself instead of a copy, so every stored subset changes later, and forgetting the empty subset.
pythondef subsets(items): out = [] def build(i, chosen): if i == len(items): out.append(list(chosen)) return build(i + 1, chosen) chosen.append(items[i]) build(i + 1, chosen) chosen.pop() build(0, []) return outjavaimport java.util.*; class Subsets { static List<List<Integer>> subsets(int[] items) { List<List<Integer>> out = new ArrayList<>(); build(items, 0, new ArrayList<>(), out); return out; } private static void build(int[] a, int i, List<Integer> chosen, List<List<Integer>> out) { if (i == a.length) { out.add(new ArrayList<>(chosen)); return; } build(a, i + 1, chosen, out); chosen.add(a[i]); build(a, i + 1, chosen, out); chosen.remove(chosen.size() - 1); } }7 Sort an array with bubble sort and report how many swaps it made.
easyRepeatedly sweep the array, swapping adjacent items that are out of order and counting each swap. Stop early when a sweep makes no swap. The swap count equals the number of inversions. O(n^2) time worst case, O(1) space. Common mistakes: counting comparisons instead of swaps, and swapping equal neighbours, which inflates the count.
pythondef bubble_sort(a): a = list(a) swaps = 0 for end in range(len(a) - 1, 0, -1): swapped = False for i in range(end): if a[i] > a[i + 1]: a[i], a[i + 1] = a[i + 1], a[i] swaps += 1 swapped = True if not swapped: break return a, swapsjavaclass Bubble { static int sort(int[] a) { int swaps = 0; for (int end = a.length - 1; end > 0; end--) { boolean swapped = false; for (int i = 0; i < end; i++) { if (a[i] > a[i + 1]) { int t = a[i]; a[i] = a[i + 1]; a[i + 1] = t; swaps++; swapped = true; } } if (!swapped) break; } return swaps; } }8 Rotate a rectangular matrix 90 degrees clockwise.
mediumThe element at row r, column c moves to row c, column (rows - 1 - r) of a new matrix with the dimensions swapped. In Python, reversing the rows and then transposing does it. O(rows*cols) time and space. Common mistakes: assuming the matrix is square and rotating in place, and rotating anticlockwise by transposing in the wrong order.
pythondef rotate_clockwise(matrix): return [list(row) for row in zip(*matrix[::-1])]javaclass Matrix { static int[][] rotateClockwise(int[][] m) { int rows = m.length, cols = m[0].length; int[][] out = new int[cols][rows]; for (int r = 0; r < rows; r++) for (int c = 0; c < cols; c++) out[c][rows - 1 - r] = m[r][c]; return out; } }9 Check whether one string is a rotation of another.
easyTwo strings of equal length are rotations of each other exactly when the second appears inside the first written twice. Check the lengths first. O(n) with a linear-time substring search (the built-in search may be worse in the worst case). Common mistakes: skipping the length check, so a shorter substring wrongly matches, and testing both strings for being anagrams, which is a weaker condition.
pythondef is_rotation(a, b): return len(a) == len(b) and b in a + ajavaclass Rotation { static boolean isRotation(String a, String b) { return a.length() == b.length() && (a + a).contains(b); } }10 SQL: count candidates in each score band, where 75 and above is A, 50 to 74 is B and below 50 is C. Table assessments(id, candidate, score).
easyCompute the band with a CASE expression, then group by it. Put the conditions in descending order so each row takes the first matching band. Common mistakes: grouping by score rather than by the band, and writing overlapping ranges so a row seems to fit two bands, though CASE stops at the first match.
sqlSELECT CASE WHEN score >= 75 THEN 'A' WHEN score >= 50 THEN 'B' ELSE 'C' END AS band, COUNT(*) AS candidates FROM assessments GROUP BY CASE WHEN score >= 75 THEN 'A' WHEN score >= 50 THEN 'B' ELSE 'C' END ORDER BY band;11 SQL: list every client with the number of support tickets they raised, including clients with none. Tables clients(id, name) and tickets(id, client_id, status, priority).
mediumLeft join clients to tickets and count a column from the tickets side. COUNT(t.id) counts only real matches, so a client with no tickets gets zero, whereas COUNT(*) would report one. Group by the client. Common mistakes: using an inner join, which drops quiet clients, and using COUNT(*) on a left join.
sqlSELECT c.name, COUNT(t.id) AS tickets FROM clients c LEFT JOIN tickets t ON t.client_id = c.id GROUP BY c.id, c.name ORDER BY c.name;12 SQL: for each client, show total tickets and how many are still open. Table tickets(id, client_id, status, priority).
mediumUse conditional aggregation: SUM of a CASE that returns 1 for open tickets and 0 otherwise, beside a plain COUNT. One pass over the table and no self join. Order by open tickets so the busiest clients come first. Common mistakes: filtering WHERE status = 'open', which loses the total, and using COUNT with a CASE that returns 0 (COUNT counts non-NULL values, and 0 is not NULL).
sqlSELECT client_id, COUNT(*) AS total_tickets, SUM(CASE WHEN status = 'open' THEN 1 ELSE 0 END) AS open_tickets FROM tickets GROUP BY client_id ORDER BY open_tickets DESC, client_id;
Frequently asked questions
What are DXC coding tests like?
Commonly shared accounts describe basic to medium coding questions and technical multiple-choice questions. The exact mix varies by role and drive, so confirm the details with the instructions you receive.
Why does this set include fixed-width parsing and log counting?
IT services work involves a lot of batch files and logs. Those tasks exercise string slicing, counting and defensive input handling, which are also staples of entry-level tests.
How important is recursion?
It is a frequent topic in fresher tests. The four recursion problems here use a base case, a smaller subproblem and a combining step; if you can state those three parts, most recursion questions follow.
Which language is best?
Use whichever you can write correctly without looking things up. Python is shorter, and Java is a good choice if your college courses used it.
Where do I check real openings?
On DXC Technology's own careers site. Nothing on this page is an official announcement of any drive.
Related guides
More in Company Interview Questions
- DXC Technology interview questions and answers
- EPAM Coding Round Questions
- EPAM Interview Questions with Answers
- EY coding round questions
- EY interview questions and answers
- Fidelity Investments coding round questions with solutions
- Fidelity Investments interview questions with answers (engineers)
- Flipkart Coding Round Questions with Solutions
- Flipkart Interview Questions and Answers
- Fractal Analytics Coding Round Questions
- Fractal Analytics Interview Questions with Answers
- Freshworks Coding Round Questions with Solutions