Autocoder

Deloitte coding round questions

Last updated 2026-11-19

Deloitte's National Level Assessment, as described in third-party preparation guides, is a long online test that mixes dozens of multiple-choice questions with a pair of coding problems. The coding portion is usually described as approachable: array and string manipulation, hashing, and sometimes a database query. So the sensible way to prepare is volume and accuracy, not exotic algorithms. The twelve problems below are written with that in mind.

They are original practice problems, not a copy of any NLA paper. For the interview rounds that follow the test, read Deloitte interview questions. The DSA coding round guide covers pacing, and Deloitte hiring has sourced news.

Reported test shape65 MCQs and 2 coding questions in about 90 minutes (2025 guides)
Difficulty hereEasy to medium, plus SQL
MonitoringMonitored online test

Time budgeting for a mixed paper

A paper that carries many multiple-choice questions and only two programs punishes anyone who burns half the clock on a single bug. A workable split is to clear the multiple-choice questions you are sure about, bank the quick coding problem first, and return to the harder one with whatever remains.

Because the coding problems are described as easy to medium, the marks usually go to completeness: handle the empty input, a single element and repeated values, then print in exactly the format the statement gives.

What the monitoring means for practice

Guides describe the test as taken online under proctoring. Practise in similar conditions: a single screen, no notes, a plain editor and a timer. The habits you build when nobody can help you are the ones that carry over. If you are considering any tool on test day, read is it safe and your invitation's rules first.

Hiring status

For current news see Deloitte hiring. The sourced facts held here are that the NLA registration window closed on 13 January 2025 and ran from 19 to 21 January 2026, and that 2027 dates have not been announced. Test format details above come from third-party guides. Register on Deloitte's own recruiting site, usrecruiting.deloitte.com.

Deloitte coding round questions: questions with worked answers

  1. 1

    Return the first character of a string that never repeats.

    easy

    Count every character in a first pass, then scan the string again and return the first one whose count is one. If none exists, return a sentinel such as None. O(n) time, O(k) space for k distinct characters. Common mistakes: using the string's index and rindex methods inside a loop, which is quadratic, and returning the character with the smallest count rather than the first unique by position.

    python
    from collections import Counter
    
    def first_unique(text):
        counts = Counter(text)
        for ch in text:
            if counts[ch] == 1:
                return ch
        return None
    java
    import java.util.*;
    
    class Unique {
        static Character firstUnique(String s) {
            Map<Character, Integer> counts = new LinkedHashMap<>();
            for (char c : s.toCharArray()) counts.merge(c, 1, Integer::sum);
            for (Map.Entry<Character, Integer> e : counts.entrySet())
                if (e.getValue() == 1) return e.getKey();
            return null;
        }
    }
  2. 2

    Remove duplicates from a sorted array in place and return the new length.

    easy

    Use a slow pointer for the next write position and a fast pointer that scans. Whenever the fast value differs from the last kept value, write it at the slow position and advance. O(n) time, O(1) space. Common mistakes: building a new list when in-place is demanded, and starting the slow pointer at zero for an empty array.

    python
    def dedupe_sorted(a):
        if not a:
            return 0
        write = 1
        for read in range(1, len(a)):
            if a[read] != a[write - 1]:
                a[write] = a[read]
                write += 1
        return write
    java
    class Dedupe {
        static int dedupeSorted(int[] a) {
            if (a.length == 0) return 0;
            int write = 1;
            for (int read = 1; read < a.length; read++)
                if (a[read] != a[write - 1]) a[write++] = a[read];
            return write;
        }
    }
  3. 3

    Decide whether two strings are anagrams of each other.

    easy

    Compare character counts. Increment a counter for each character of the first string, decrement for the second, and check that every counter ends at zero. Different lengths fail at once. O(n) time, O(1) space for a fixed alphabet. Common mistakes: ignoring case when the statement says to, and comparing only the sets of characters, which misses differing counts.

    python
    from collections import Counter
    
    def is_anagram(a, b):
        return len(a) == len(b) and Counter(a.lower()) == Counter(b.lower())
    java
    class Anagram {
        static boolean isAnagram(String a, String b) {
            if (a.length() != b.length()) return false;
            int[] diff = new int[65536];
            for (int i = 0; i < a.length(); i++) {
                diff[Character.toLowerCase(a.charAt(i))]++;
                diff[Character.toLowerCase(b.charAt(i))]--;
            }
            for (int d : diff) if (d != 0) return false;
            return true;
        }
    }
  4. 4

    Merge two sorted arrays into one sorted array.

    easy

    Keep one index per array and repeatedly take the smaller front element. When one array runs out, copy the rest of the other. O(m + n) time and space. Common mistakes: concatenating and sorting, which is slower and often rejected, and forgetting to copy the leftover tail.

    python
    def merge_sorted(a, b):
        i = j = 0
        out = []
        while i < len(a) and j < len(b):
            if a[i] <= b[j]:
                out.append(a[i]); i += 1
            else:
                out.append(b[j]); j += 1
        return out + a[i:] + b[j:]
    java
    class MergeTwo {
        static int[] merge(int[] a, int[] b) {
            int[] out = new int[a.length + b.length];
            int i = 0, j = 0, k = 0;
            while (i < a.length && j < b.length) out[k++] = a[i] <= b[j] ? a[i++] : b[j++];
            while (i < a.length) out[k++] = a[i++];
            while (j < b.length) out[k++] = b[j++];
            return out;
        }
    }
  5. 5

    Find the element that appears more than half the time, if there is one.

    medium

    Boyer-Moore voting. Keep a candidate and a counter: a matching element raises the counter, a different one lowers it, and a zero counter picks a new candidate. A second pass confirms the candidate really is a majority. O(n) time, O(1) space. Common mistakes: skipping the confirmation pass, which returns a wrong answer when no majority exists.

    python
    def majority(nums):
        candidate, votes = None, 0
        for x in nums:
            if votes == 0:
                candidate = x
            votes += 1 if x == candidate else -1
        return candidate if nums.count(candidate) * 2 > len(nums) else None
    java
    class Majority {
        static Integer majority(int[] nums) {
            int candidate = 0, votes = 0;
            for (int x : nums) {
                if (votes == 0) candidate = x;
                votes += x == candidate ? 1 : -1;
            }
            int count = 0;
            for (int x : nums) if (x == candidate) count++;
            return count * 2 > nums.length ? candidate : null;
        }
    }
  6. 6

    Print the three most frequent words in a paragraph, breaking ties alphabetically.

    medium

    Lowercase the text, split into words, count with a hash map, then sort the pairs by descending count and ascending word and take three. O(n + m log m) for m distinct words. Common mistakes: leaving punctuation attached to words so that the same word counts twice, and sorting by count alone so ties come out in arbitrary order.

    python
    import re
    from collections import Counter
    
    def top_three(paragraph):
        words = re.findall(r'[a-z0-9]+', paragraph.lower())
        ranked = sorted(Counter(words).items(), key=lambda kv: (-kv[1], kv[0]))
        return [w for w, _ in ranked[:3]]
    java
    import java.util.*;
    
    class TopWords {
        static List<String> topThree(String text) {
            Map<String, Integer> counts = new HashMap<>();
            for (String w : text.toLowerCase().split("[^a-z0-9]+"))
                if (!w.isEmpty()) counts.merge(w, 1, Integer::sum);
            List<Map.Entry<String, Integer>> list = new ArrayList<>(counts.entrySet());
            list.sort((a, b) -> a.getValue().equals(b.getValue()) ? a.getKey().compareTo(b.getKey()) : b.getValue() - a.getValue());
            List<String> out = new ArrayList<>();
            for (int i = 0; i < Math.min(3, list.size()); i++) out.add(list.get(i).getKey());
            return out;
        }
    }
  7. 7

    Given a date as day, month and year, return its position in the year.

    easy

    Add the days of all earlier months, then the day of the month. February has 29 days in a leap year: divisible by 4, except century years unless divisible by 400. O(1) time. Common mistakes: using the rule divisible by 4 alone, so 1900 is wrongly a leap year, and adding February's extra day when the date is in January.

    python
    def day_of_year(day, month, year):
        leap = year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
        lengths = [31, 29 if leap else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
        return sum(lengths[:month - 1]) + day
    java
    class DayOfYear {
        static int dayOfYear(int day, int month, int year) {
            boolean leap = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
            int[] len = {31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int total = day;
            for (int m = 0; m < month - 1; m++) total += len[m];
            return total;
        }
    }
  8. 8

    Check that a string of brackets ()[]{} is balanced and correctly nested.

    easy

    Push each opening bracket onto a stack. For a closing bracket, the stack must be non-empty and its top must be the matching opener, otherwise fail. The string is valid only if the stack is empty at the end. O(n) time, O(n) space. Common mistakes: counting brackets by type, which accepts ([)], and popping from an empty stack.

    python
    def balanced(text):
        pairs = {')': '(', ']': '[', '}': '{'}
        stack = []
        for ch in text:
            if ch in '([{':
                stack.append(ch)
            elif ch in pairs:
                if not stack or stack.pop() != pairs[ch]:
                    return False
        return not stack
    java
    import java.util.*;
    
    class Brackets {
        static boolean balanced(String s) {
            Deque<Character> stack = new ArrayDeque<>();
            for (char c : s.toCharArray()) {
                if (c == '(' || c == '[' || c == '{') stack.push(c);
                else if (c == ')' || c == ']' || c == '}') {
                    if (stack.isEmpty()) return false;
                    char open = stack.pop();
                    if ((c == ')' && open != '(') || (c == ']' && open != '[') || (c == '}' && open != '{')) return false;
                }
            }
            return stack.isEmpty();
        }
    }
  9. 9

    Move all zeros to the end of an array while keeping the order of the other elements.

    easy

    Keep a write index for the next non-zero slot. Scan once; every non-zero value is written at the write index, which then advances. Fill the remaining positions with zeros. O(n) time, O(1) space. Common mistakes: swapping in a way that disturbs the relative order, and using a second list when the statement asks for in-place.

    python
    def zeros_to_end(a):
        write = 0
        for x in a:
            if x != 0:
                a[write] = x
                write += 1
        for i in range(write, len(a)):
            a[i] = 0
        return a
    java
    class Zeros {
        static void zerosToEnd(int[] a) {
            int write = 0;
            for (int x : a) if (x != 0) a[write++] = x;
            while (write < a.length) a[write++] = 0;
        }
    }
  10. 10

    SQL: find every email address that appears more than once in users(id, email).

    easy

    Group by the email and keep groups with a count above one using HAVING. HAVING filters groups after aggregation, whereas WHERE filters rows before it. Common mistakes: using WHERE COUNT(*) > 1, which is a syntax error, and ignoring case differences when the emails were entered by hand; lower-casing in the GROUP BY handles that.

    sql
    SELECT LOWER(email) AS email, COUNT(*) AS copies
    FROM users
    GROUP BY LOWER(email)
    HAVING COUNT(*) > 1
    ORDER BY email;
  11. 11

    SQL: show each payment with a running total of amounts in date order. Table payments(id, paid_on, amount).

    medium

    Use a window function: SUM(amount) OVER (ORDER BY paid_on, id). The id is a tiebreaker so that two payments on the same day get a stable running order. The window default frame includes everything from the first row up to the current one. Common mistakes: using GROUP BY, which collapses the rows, and leaving out a tiebreaker so equal dates produce an arbitrary order.

    sql
    SELECT id, paid_on, amount,
           SUM(amount) OVER (ORDER BY paid_on, id) AS running_total
    FROM payments
    ORDER BY paid_on, id;
  12. 12

    SQL: list employees paid more than the average salary of their own department. Table employees(id, name, dept_id, salary).

    medium

    Join each employee to a derived table that holds the average salary per department, then compare. A correlated subquery in the WHERE clause also works but may recompute the average per row on some engines. Common mistakes: comparing against the company-wide average, and using integer division on an integer average in engines that truncate; cast to a decimal when the engine requires it.

    sql
    SELECT e.name, e.dept_id, e.salary
    FROM employees e
    JOIN (SELECT dept_id, AVG(salary) AS avg_salary
          FROM employees
          GROUP BY dept_id) d ON d.dept_id = e.dept_id
    WHERE e.salary > d.avg_salary
    ORDER BY e.name;

Frequently asked questions

What is in the Deloitte NLA coding section?

Third-party guides report two coding questions alongside a large set of multiple-choice questions, with the whole test lasting around ninety minutes. Treat that as a reported format and check your own instructions.

Is SQL tested?

Guides mention database questions in some tracks. The three queries above cover grouping, window functions and joins with aggregates, which are the usual targets.

How should I split time between MCQs and coding?

Answer the multiple-choice questions you are certain about quickly, solve the easier coding problem next, and then return to the rest. Do not leave both programs for the last ten minutes.

Which language should I choose?

Pick the one in which you are fastest and least likely to make syntax errors. Python is compact for string and array tasks, and Java is a fine choice if you practise with it daily.

Where can I check the registration dates?

The sourced dates are in the hiring status section above, and the company's own recruiting site is the final authority.

Sources

Related guides

More in Company Interview Questions

See all in this section