Autocoder

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 hereEasy to medium
LanguagesPython, 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

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. 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.

    easy

    Slice 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.

    python
    def parse_record(line):
        return {
            'id': int(line[0:6]),
            'name': line[6:26].strip(),
            'balance_cents': int(line[26:36]),
        }
    java
    class 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. 2

    Count how many log lines there are at each level (INFO, WARN, ERROR) when each line looks like: date time LEVEL message.

    easy

    Split 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.

    python
    def 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 counts
    java
    import 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. 3

    How many trailing zeros does n factorial have?

    medium

    Each 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.

    python
    def trailing_zeros(n):
        count = 0
        while n:
            n //= 5
            count += n
        return count
    java
    class Factorial {
        static long trailingZeros(long n) {
            long count = 0;
            while (n > 0) {
                n /= 5;
                count += n;
            }
            return count;
        }
    }
  4. 4

    Write recursive functions for the GCD and the LCM of two positive integers.

    easy

    Euclid'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.

    python
    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)
    
    def lcm(a, b):
        return a // gcd(a, b) * b
    java
    class 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. 5

    List the moves that solve the Tower of Hanoi for n discs.

    medium

    Move 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.

    python
    def hanoi(n, source, target, spare):
        if n == 0:
            return []
        return (hanoi(n - 1, source, spare, target)
                + [(source, target)]
                + hanoi(n - 1, spare, target, source))
    java
    import 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. 6

    Generate every subset of a list of distinct items.

    medium

    Decide 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.

    python
    def 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 out
    java
    import 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. 7

    Sort an array with bubble sort and report how many swaps it made.

    easy

    Repeatedly 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.

    python
    def 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, swaps
    java
    class 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. 8

    Rotate a rectangular matrix 90 degrees clockwise.

    medium

    The 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.

    python
    def rotate_clockwise(matrix):
        return [list(row) for row in zip(*matrix[::-1])]
    java
    class 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. 9

    Check whether one string is a rotation of another.

    easy

    Two 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.

    python
    def is_rotation(a, b):
        return len(a) == len(b) and b in a + a
    java
    class Rotation {
        static boolean isRotation(String a, String b) {
            return a.length() == b.length() && (a + a).contains(b);
        }
    }
  10. 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).

    easy

    Compute 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.

    sql
    SELECT 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. 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).

    medium

    Left 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.

    sql
    SELECT 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. 12

    SQL: for each client, show total tickets and how many are still open. Table tickets(id, client_id, status, priority).

    medium

    Use 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).

    sql
    SELECT 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

See all in this section