Autocoder

NTT DATA coding round questions

Last updated 2026-11-19

NTT DATA delivers application, infrastructure and business-process services to banks, telecom operators, insurers and public bodies, and its entry-level hiring is commonly described as a multi-part online assessment: aptitude, English and a technical section that includes some programming. NTT DATA has not published a syllabus we can cite. The twelve problems below are therefore practice built around the kind of work that those clients send, such as card validation, bill calculation and cheque printing.

Ten are solved in Python and Java and two are SQL queries. Each solution explains the approach, the running cost and the slip to avoid. For the later rounds, read NTT DATA interview questions.

Round style (commonly reported)Aptitude, English and technical sections with basic coding
Practice difficultyEasy to medium
Code shownPython and Java, plus two SQL queries

What a mixed-section test asks of you

A test that combines verbal, quantitative and technical sections is a time-allocation puzzle as much as a coding one. A common plan is to bank the quickest marks first, give coding a fixed slice, and return to leftovers. If a medium problem is eating your slice, submit what passes and move on.

Problems on this page are deliberately procedural. Many of them (a bill by slabs, a number spelled in words, a card checksum) have no clever trick, only a careful sequence of steps. The marks go to whoever follows the steps without dropping a boundary case.

Boundary cases worth testing every time

Hiring status

This page carries no sourced NTT DATA statement on fresher numbers, dates or eligibility, so none are stated. Use your invitation and NTT DATA's careers site for the real pattern. If the English section worries you, aptitude practice is a sensible companion.

NTT DATA coding round questions: questions with worked answers

  1. 1

    A form field holds an address line. Count its vowels, consonants, digits and other characters (spaces and punctuation).

    easy

    Classify each character exactly once. Lower-case it, test for a vowel, then for any other letter, then for a digit, and put the rest in the fourth bucket. O(n) time, O(1) space. The usual error is counting a vowel again as a consonant, or treating a space as a consonant because only the vowel test was written.

    python
    def classify(text):
        v = c = d = o = 0
        for ch in text.lower():
            if ch in "aeiou":
                v += 1
            elif "a" <= ch <= "z":
                c += 1
            elif "0" <= ch <= "9":
                d += 1
            else:
                o += 1
        return v, c, d, o
    java
    class Address {
        static int[] classify(String text) {
            int[] r = new int[4];
            for (char ch : text.toLowerCase().toCharArray()) {
                if ("aeiou".indexOf(ch) >= 0) r[0]++;
                else if (ch >= 'a' && ch <= 'z') r[1]++;
                else if (ch >= '0' && ch <= '9') r[2]++;
                else r[3]++;
            }
            return r;
        }
    }
  2. 2

    Check a payment card number with the Luhn checksum: from the right, double every second digit, subtract 9 from any result above 9, sum everything, and test divisibility by 10.

    medium

    Walk from the rightmost digit with an index. Odd positions (second, fourth and so on from the right) are doubled. O(n) time and O(1) space. The most common error is doubling from the left, which only works for even-length numbers. Strip spaces and hyphens first, and reject inputs with no digits.

    python
    def luhn_ok(num):
        digits = [int(ch) for ch in num if ch.isdigit()]
        if not digits:
            return False
        total = 0
        for i, d in enumerate(reversed(digits)):
            if i % 2 == 1:
                d *= 2
                if d > 9:
                    d -= 9
            total += d
        return total % 10 == 0
    java
    class Luhn {
        static boolean luhnOk(String num) {
            int total = 0, pos = 0;
            for (int i = num.length() - 1; i >= 0; i--) {
                char ch = num.charAt(i);
                if (ch < '0' || ch > '9') continue;
                int d = ch - '0';
                if (pos % 2 == 1) {
                    d *= 2;
                    if (d > 9) d -= 9;
                }
                total += d;
                pos++;
            }
            return pos > 0 && total % 10 == 0;
        }
    }
  3. 3

    Print a cheque amount between 1 and 999 in words, for example 342 as "three hundred forty-two".

    medium

    Split into hundreds and the remainder. Spell the hundreds digit, then handle the remainder below 20 from a lookup table and the rest as a tens word plus an optional ones word joined by a hyphen. Constant time. Typical mistakes are printing "zero" inside a number such as 305, and spelling 15 as "ten five" because the teens were not given their own table entries.

    python
    ONES = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
            "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
            "seventeen", "eighteen", "nineteen"]
    TENS = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
    
    def in_words(n):
        parts = []
        h, r = divmod(n, 100)
        if h:
            parts.append(ONES[h] + " hundred")
        if r:
            if r < 20:
                parts.append(ONES[r])
            else:
                t, o = divmod(r, 10)
                parts.append(TENS[t] + ("-" + ONES[o] if o else ""))
        return " ".join(parts)
    java
    class Cheque {
        static final String[] ONES = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
            "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
        static final String[] TENS = {"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
    
        static String inWords(int n) {
            StringBuilder sb = new StringBuilder();
            int h = n / 100, r = n % 100;
            if (h > 0) sb.append(ONES[h]).append(" hundred");
            if (r > 0) {
                if (sb.length() > 0) sb.append(' ');
                if (r < 20) sb.append(ONES[r]);
                else {
                    sb.append(TENS[r / 10]);
                    if (r % 10 > 0) sb.append('-').append(ONES[r % 10]);
                }
            }
            return sb.toString();
        }
    }
  4. 4

    Given an unsorted array of loan application numbers, find the smallest positive integer that is missing, in O(n) time and O(1) extra space.

    hard

    Cyclic placement. The answer lies between 1 and n + 1, so try to place each value v in the range 1..n at index v - 1 by swapping, skipping values that are out of range or already in place. A second scan finds the first index holding the wrong value. Each swap puts one value home, so O(n) overall. Looping with an if instead of a while leaves misplaced values behind.

    python
    def first_missing(a):
        n = len(a)
        for i in range(n):
            while 1 <= a[i] <= n and a[a[i] - 1] != a[i]:
                j = a[i] - 1
                a[i], a[j] = a[j], a[i]
        for i in range(n):
            if a[i] != i + 1:
                return i + 1
        return n + 1
    java
    class Missing {
        static int firstMissing(int[] a) {
            int n = a.length;
            for (int i = 0; i < n; i++) {
                while (a[i] >= 1 && a[i] <= n && a[a[i] - 1] != a[i]) {
                    int j = a[i] - 1, t = a[i];
                    a[i] = a[j];
                    a[j] = t;
                }
            }
            for (int i = 0; i < n; i++) {
                if (a[i] != i + 1) return i + 1;
            }
            return n + 1;
        }
    }
  5. 5

    Repeatedly delete pairs of equal adjacent characters from a string until none remain. For "abbaca" the result is "ca".

    easy

    Stack of kept characters. For each new character, if it equals the top of the stack, pop; otherwise push. The stack contents are the answer. O(n) time and space. Doing repeated string replacement passes also works but is O(n^2) on strings like "abcddcba", and removing only one round of pairs misses the new pairs created when two characters become adjacent.

    python
    def squash(s):
        st = []
        for ch in s:
            if st and st[-1] == ch:
                st.pop()
            else:
                st.append(ch)
        return "".join(st)
    java
    class Squash {
        static String squash(String s) {
            StringBuilder st = new StringBuilder();
            for (char ch : s.toCharArray()) {
                int top = st.length() - 1;
                if (top >= 0 && st.charAt(top) == ch) st.deleteCharAt(top);
                else st.append(ch);
            }
            return st.toString();
        }
    }
  6. 6

    A grid marks occupied (1) and empty (0) service counters. Count the clusters of occupied counters, where counters touching up, down, left or right belong to one cluster.

    medium

    Flood fill. Scan the grid; on meeting an unvisited 1, increase the count and flood through its four neighbours with a queue, marking cells as visited. Each cell is handled once, so O(rows x cols) time and space. Use an explicit queue rather than recursion on large grids to avoid stack overflow, and do not include diagonal neighbours unless the statement says so.

    python
    from collections import deque
    
    def count_clusters(grid):
        rows, cols = len(grid), len(grid[0]) if grid else 0
        seen, count = set(), 0
        for r in range(rows):
            for c in range(cols):
                if grid[r][c] == 1 and (r, c) not in seen:
                    count += 1
                    seen.add((r, c))
                    q = deque([(r, c)])
                    while q:
                        x, y = q.popleft()
                        for nx, ny in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)):
                            if 0 <= nx < rows and 0 <= ny < cols and grid[nx][ny] == 1 and (nx, ny) not in seen:
                                seen.add((nx, ny))
                                q.append((nx, ny))
        return count
    java
    import java.util.*;
    class Clusters {
        static int countClusters(int[][] g) {
            int rows = g.length, cols = rows == 0 ? 0 : g[0].length, count = 0;
            int[] dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
            for (int r = 0; r < rows; r++) {
                for (int c = 0; c < cols; c++) {
                    if (g[r][c] != 1) continue;
                    count++;
                    g[r][c] = 2;
                    Deque<int[]> q = new ArrayDeque<>();
                    q.add(new int[]{r, c});
                    while (!q.isEmpty()) {
                        int[] cur = q.poll();
                        for (int k = 0; k < 4; k++) {
                            int nx = cur[0] + dx[k], ny = cur[1] + dy[k];
                            if (nx >= 0 && nx < rows && ny >= 0 && ny < cols && g[nx][ny] == 1) {
                                g[nx][ny] = 2;
                                q.add(new int[]{nx, ny});
                            }
                        }
                    }
                }
            }
            return count;
        }
    }
  7. 7

    An electricity bill is charged by slabs: 3 per unit for the first 100 units, 5 per unit for the next 100, and 8 per unit beyond that. Compute the bill for a number of units.

    easy

    Progressive slabs. For each slab take the smaller of the units left and the slab size, multiply by its rate and subtract from the remaining units. O(1) for a fixed slab table. The rates here are illustrative, not a real tariff. The classic mistake is charging every unit at the top slab's rate, instead of only the units that fall inside it.

    python
    def bill(units):
        total = 0
        for size, rate in ((100, 3), (100, 5), (float("inf"), 8)):
            take = min(units, size)
            total += take * rate
            units -= take
            if units <= 0:
                break
        return total
    java
    class Tariff {
        static long bill(long units) {
            long[] size = {100, 100, Long.MAX_VALUE};
            int[] rate = {3, 5, 8};
            long total = 0;
            for (int i = 0; i < 3 && units > 0; i++) {
                long take = Math.min(units, size[i]);
                total += take * rate[i];
                units -= take;
            }
            return total;
        }
    }
  8. 8

    Repeatedly add the digits of a non-negative number until a single digit remains, for a check-digit display. What is the result for 98765?

    easy

    Digital root. Looping works: sum the digits until the value is below ten. A closed form also exists: for n above zero the root is 1 + (n - 1) mod 9, and zero maps to zero. The loop is O(log n) per round, the formula O(1). For 98765 the digit sum is 35, then 8. Using n mod 9 directly fails for multiples of 9, which should give 9 and not 0.

    python
    def digital_root(n):
        return 0 if n == 0 else 1 + (n - 1) % 9
    java
    class Root {
        static int digitalRoot(long n) {
            return n == 0 ? 0 : (int) (1 + (n - 1) % 9);
        }
    }
  9. 9

    Return the longest palindromic substring of a string, such as a reference code.

    medium

    Expand around centres. A palindrome mirrors around a centre that is either a character or a gap between two characters, giving 2n - 1 centres. Expand outward from each while the ends match and keep the longest span. O(n^2) time, O(1) space, which is enough for typical limits. Handling only odd-length centres misses answers like "abba".

    python
    def longest_pal(s):
        best = (0, 0)
        for centre in range(2 * len(s) - 1):
            lo, hi = centre // 2, centre // 2 + centre % 2
            while lo >= 0 and hi < len(s) and s[lo] == s[hi]:
                lo, hi = lo - 1, hi + 1
            if hi - lo - 1 > best[1] - best[0]:
                best = (lo + 1, hi)
        return s[best[0]:best[1]]
    java
    class Pal {
        static String longestPal(String s) {
            int start = 0, len = 0;
            for (int centre = 0; centre < 2 * s.length() - 1; centre++) {
                int lo = centre / 2, hi = lo + centre % 2;
                while (lo >= 0 && hi < s.length() && s.charAt(lo) == s.charAt(hi)) { lo--; hi++; }
                if (hi - lo - 1 > len) { len = hi - lo - 1; start = lo + 1; }
            }
            return s.substring(start, start + len);
        }
    }
  10. 10

    Decide whether a sentence is a pangram, meaning it uses every letter of the English alphabet at least once, ignoring case.

    easy

    Presence set. Collect the alphabetic characters in lower case into a set or a 26-slot boolean array and check that all 26 are present. O(n) time, O(1) space. Counting total letters instead of distinct letters is the common mistake, and so is forgetting to ignore digits and punctuation.

    python
    def is_pangram(s):
        return len({ch for ch in s.lower() if "a" <= ch <= "z"}) == 26
    java
    class Pangram {
        static boolean isPangram(String s) {
            boolean[] seen = new boolean[26];
            int found = 0;
            for (char ch : s.toLowerCase().toCharArray()) {
                if (ch >= 'a' && ch <= 'z' && !seen[ch - 'a']) {
                    seen[ch - 'a'] = true;
                    found++;
                }
            }
            return found == 26;
        }
    }
  11. 11

    Table staff(id, name, salary, manager_id). List the staff who earn more than their own manager.

    medium

    Self-join. Join the table to itself, matching each employee's manager_id to the manager's id, then filter on salary. The join is an inner join, so staff without a manager drop out automatically, which is what you want. An index on id keeps it fast on large tables. The frequent mistake is joining on id = id, which compares each row with itself.

    sql
    SELECT e.name AS employee, e.salary, m.name AS manager, m.salary AS manager_salary
    FROM staff e
    JOIN staff m ON e.manager_id = m.id
    WHERE e.salary > m.salary;
  12. 12

    Table collections(collected_on, amount) holds one row per day. Return each day with a running total of the amount collected so far.

    medium

    Window function. SUM(amount) OVER (ORDER BY collected_on) accumulates in date order. With the default frame, rows that share the same date are all included together, so duplicate dates show the same running total; add ROWS UNBOUNDED PRECEDING for a strict row-by-row total. Window functions are unavailable in very old MySQL versions, where a correlated subquery is the fallback.

    sql
    SELECT collected_on,
           amount,
           SUM(amount) OVER (ORDER BY collected_on ROWS UNBOUNDED PRECEDING) AS running_total
    FROM collections
    ORDER BY collected_on;

Frequently asked questions

Is NTT DATA coding harder than the aptitude section?

Reports describe the coding as easy to medium, so the aptitude and English sections often decide how much time remains for programming. Practise all three.

Which of these problems is a good one to start with?

Begin with the address classifier and the pangram check, which take five minutes, then work towards the cheque-in-words and the cyclic-placement problem.

Do I need to know window functions?

They are worth an hour. Running totals and ranking queries appear in many technical screens for data-heavy services roles, though not guaranteed in any one test.

Can I use built-in library functions?

Usually yes unless the statement forbids it. Know what they do on edge cases, such as Python floor division with negative numbers.

Where do I confirm the real test pattern?

In your NTT DATA invitation and the careers site. This page holds no hiring dates, numbers or cutoffs.

Related guides

More in Company Interview Questions

See all in this section