Autocoder

EY coding round questions

Last updated 2026-11-19

EY's technology consulting and data roles spend a lot of time on records that arrive in poor shape: phone numbers with stray punctuation, dates in three formats, blank cells, duplicate customers. Third-party placement guides list Python, SQL, Java and programming multiple-choice questions for the tech track, so the practice set on this page leans toward data tidying and query writing, not puzzle algorithms.

The twelve problems are original and are not copies of any EY paper. For the interview that follows the test, see EY interview questions, and for query practice beyond this page use the SQL interview guide.

Reported tech topicsPython, SQL, Java, programming MCQs
Difficulty hereEasy to medium
Duration (reported)About 60 to 90 minutes, online

Why cleaning problems suit this track

A consultant on an assurance or analytics project inherits spreadsheets and exports, and the first job is making them consistent. A coding test for such a role can reasonably ask you to normalise a field, fill a gap or flag a suspicious value. These tasks are small, but they reward careful reading of the rules: what counts as valid, what to do with a value that cannot be repaired, and whether to return a new list or change the old one.

When you practise, always decide the failure behaviour first. For each function below the sample returns None when it cannot produce a clean value, which is a sensible default that a caller can test for.

SQL beyond the basics

Ranking queries (nth highest, top n per group) and clean-up queries (de-duplicate, standardise labels) are the shapes that separate a prepared candidate from one who only knows SELECT and JOIN. Make sure you can write each from a blank editor, and know the difference between ROW_NUMBER, RANK and DENSE_RANK.

Hiring status

No sourced EY statement on fresher hiring numbers or dates is held on this site, so none appear here. Format details come from third-party guides. Apply and confirm test details through EY's own careers site, ey.com/en_in/careers.

EY coding round questions: questions with worked answers

  1. 1

    Normalise an Indian mobile number typed in many styles to its ten digits, or reject it.

    easy

    Strip everything that is not a digit. Drop a leading 91 when twelve digits remain, or a leading 0 when eleven remain. What is left must be ten digits starting with 6, 7, 8 or 9, otherwise return None. O(n) time. Common mistakes: dropping a leading 91 from a ten-digit number that legitimately starts with 91, and accepting numbers that start with 0 to 5.

    python
    import re
    
    def clean_phone(raw):
        digits = re.sub(r'\D', '', raw)
        if len(digits) == 12 and digits.startswith('91'):
            digits = digits[2:]
        elif len(digits) == 11 and digits.startswith('0'):
            digits = digits[1:]
        return digits if len(digits) == 10 and digits[0] in '6789' else None
    java
    class Phone {
        static String clean(String raw) {
            String d = raw.replaceAll("\\D", "");
            if (d.length() == 12 && d.startsWith("91")) d = d.substring(2);
            else if (d.length() == 11 && d.startsWith("0")) d = d.substring(1);
            return d.length() == 10 && "6789".indexOf(d.charAt(0)) >= 0 ? d : null;
        }
    }
  2. 2

    Convert date strings written in several formats to ISO yyyy-mm-dd.

    medium

    Try each known format in turn and return the first that parses; if none does, return None. Put unambiguous formats first and state your day-before-month assumption. O(f) per value for f formats. Common mistakes: guessing silently between day-first and month-first, and letting an exception escape from the first failing format.

    python
    from datetime import datetime
    
    FORMATS = ('%d/%m/%Y', '%d-%m-%Y', '%Y/%m/%d', '%d %b %Y')
    
    def to_iso(text):
        for fmt in FORMATS:
            try:
                return datetime.strptime(text.strip(), fmt).date().isoformat()
            except ValueError:
                continue
        return None
    java
    import java.time.LocalDate;
    import java.time.format.DateTimeFormatter;
    import java.time.format.DateTimeParseException;
    import java.util.Locale;
    
    class Dates {
        static final String[] PATTERNS = {"dd/MM/yyyy", "dd-MM-yyyy", "yyyy/MM/dd", "dd MMM yyyy"};
    
        static String toIso(String text) {
            for (String p : PATTERNS) {
                try {
                    return LocalDate.parse(text.trim(), DateTimeFormatter.ofPattern(p, Locale.ENGLISH)).toString();
                } catch (DateTimeParseException e) {
                    // try the next pattern
                }
            }
            return null;
        }
    }
  3. 3

    Replace missing readings in a column with the mean of the known ones.

    easy

    Compute the mean over the non-missing values only, then build a new list where each missing entry is replaced by it. If every entry is missing there is no mean, so return the list unchanged. O(n) time and space. Common mistakes: dividing by the full length instead of the count of known values, and treating zero as missing.

    python
    def fill_with_mean(values):
        known = [v for v in values if v is not None]
        if not known:
            return list(values)
        mean = sum(known) / len(known)
        return [mean if v is None else v for v in values]
    java
    class Fill {
        static Double[] fillWithMean(Double[] values) {
            double sum = 0;
            int known = 0;
            for (Double v : values) if (v != null) { sum += v; known++; }
            Double[] out = values.clone();
            if (known == 0) return out;
            double mean = sum / known;
            for (int i = 0; i < out.length; i++) if (out[i] == null) out[i] = mean;
            return out;
        }
    }
  4. 4

    Flag outliers in a numeric column using the 1.5 x IQR rule.

    medium

    Sort the data and split it into a lower and an upper half (leaving out the middle value when the count is odd). Q1 and Q3 are the medians of those halves, and the interquartile range is Q3 minus Q1. Anything below Q1 - 1.5*IQR or above Q3 + 1.5*IQR is an outlier. O(n log n). Common mistakes: using the mean instead of medians, and quoting quartiles from a library that uses a different interpolation without saying so.

    python
    def _median(s):
        mid = len(s) // 2
        return s[mid] if len(s) % 2 else (s[mid - 1] + s[mid]) / 2
    
    def iqr_outliers(values):
        s = sorted(values)
        n = len(s)
        q1 = _median(s[:n // 2])
        q3 = _median(s[(n + 1) // 2:])
        spread = q3 - q1
        low, high = q1 - 1.5 * spread, q3 + 1.5 * spread
        return [v for v in values if v < low or v > high]
    java
    import java.util.*;
    
    class Outliers {
        private static double median(double[] s, int from, int to) {
            int n = to - from, mid = from + n / 2;
            return n % 2 == 1 ? s[mid] : (s[mid - 1] + s[mid]) / 2;
        }
    
        static List<Double> iqr(double[] values) {
            double[] s = values.clone();
            Arrays.sort(s);
            int n = s.length;
            double q1 = median(s, 0, n / 2), q3 = median(s, (n + 1) / 2, n);
            double spread = q3 - q1, low = q1 - 1.5 * spread, high = q3 + 1.5 * spread;
            List<Double> out = new ArrayList<>();
            for (double v : values) if (v < low || v > high) out.add(v);
            return out;
        }
    }
  5. 5

    Keep only the most recent record for each customer id.

    easy

    Walk the records once, remembering for each id the entry with the latest timestamp. Replace the stored entry only when the new timestamp is strictly later. O(n) time, O(distinct ids) space. Common mistakes: assuming the input is already sorted by time, and keeping the first record seen instead of the latest.

    python
    def latest_per_id(records):
        best = {}
        for rid, stamp, value in records:
            if rid not in best or stamp > best[rid][0]:
                best[rid] = (stamp, value)
        return {rid: pair[1] for rid, pair in best.items()}
    java
    import java.util.*;
    
    class Latest {
        static Map<String, String> latestPerId(List<String[]> records) {
            Map<String, String[]> best = new HashMap<>();
            for (String[] r : records) {
                String[] cur = best.get(r[0]);
                if (cur == null || r[1].compareTo(cur[1]) > 0) best.put(r[0], r);
            }
            Map<String, String> out = new TreeMap<>();
            for (Map.Entry<String, String[]> e : best.entrySet()) out.put(e.getKey(), e.getValue()[2]);
            return out;
        }
    }
  6. 6

    Compute the average amount per group, rounded to two decimals, from (group, amount) rows.

    easy

    Keep a running sum and a count per group in a hash map, then divide at the end. O(n) time, O(groups) space. Common mistakes: averaging the group averages, which is wrong when group sizes differ, and rounding before the final division.

    python
    def average_by_group(rows):
        totals = {}
        for group, amount in rows:
            s, c = totals.get(group, (0, 0))
            totals[group] = (s + amount, c + 1)
        return {g: round(s / c, 2) for g, (s, c) in sorted(totals.items())}
    java
    import java.util.*;
    
    class Averages {
        static Map<String, Double> averageByGroup(String[] groups, double[] amounts) {
            Map<String, double[]> acc = new TreeMap<>();
            for (int i = 0; i < groups.length; i++) {
                double[] a = acc.computeIfAbsent(groups[i], k -> new double[2]);
                a[0] += amounts[i];
                a[1] += 1;
            }
            Map<String, Double> out = new TreeMap<>();
            for (Map.Entry<String, double[]> e : acc.entrySet())
                out.put(e.getKey(), Math.round(e.getValue()[0] / e.getValue()[1] * 100) / 100.0);
            return out;
        }
    }
  7. 7

    Run-length compress a string, so that aaabbc becomes a3b2c1.

    easy

    Walk the string while counting the length of each run of equal characters, and append the character and the count when the run ends. Remember to flush the final run after the loop. O(n) time and space. Common mistakes: forgetting the last run, and returning an empty string for an empty input incorrectly because of indexing the first character.

    python
    def compress(text):
        if not text:
            return ''
        out, run, prev = [], 1, text[0]
        for ch in text[1:]:
            if ch == prev:
                run += 1
            else:
                out.append(prev + str(run))
                prev, run = ch, 1
        out.append(prev + str(run))
        return ''.join(out)
    java
    class Rle {
        static String compress(String s) {
            if (s.isEmpty()) return "";
            StringBuilder sb = new StringBuilder();
            char prev = s.charAt(0);
            int run = 1;
            for (int i = 1; i < s.length(); i++) {
                if (s.charAt(i) == prev) run++;
                else { sb.append(prev).append(run); prev = s.charAt(i); run = 1; }
            }
            return sb.append(prev).append(run).toString();
        }
    }
  8. 8

    Flatten a list that contains lists nested to any depth.

    medium

    Recursion: for each item, if it is itself a list flatten it and extend the output, otherwise append it. Depth is bounded by the nesting level, so stack use is O(depth), with O(n) for the output. Common mistakes: treating a string as a list and splitting it into characters, and flattening only one level.

    python
    def flatten(items):
        out = []
        for item in items:
            if isinstance(item, list):
                out.extend(flatten(item))
            else:
                out.append(item)
        return out
    java
    import java.util.*;
    
    class Flat {
        static void flatten(List<?> items, List<Object> out) {
            for (Object o : items) {
                if (o instanceof List) flatten((List<?>) o, out);
                else out.add(o);
            }
        }
    }
  9. 9

    SQL: find the nth highest distinct salary. Table employees(id, name, salary).

    medium

    Rank the distinct salaries with DENSE_RANK in descending order and pick rank n (the query shown uses n = 3). DENSE_RANK gives equal salaries the same rank and does not leave gaps, which is what nth highest distinct means. Return no row if fewer than n distinct salaries exist. Common mistakes: using ROW_NUMBER, which counts duplicates separately, and using LIMIT with OFFSET without DISTINCT.

    sql
    SELECT salary
    FROM (SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS r
          FROM employees) ranked
    WHERE r = 3
    GROUP BY salary;
  10. 10

    SQL: show the two highest-paid employees in every department. Table employees(id, name, dept_id, salary).

    medium

    Number the rows within each department using ROW_NUMBER with PARTITION BY dept_id and ORDER BY salary descending, then keep numbers 1 and 2 from the outer query. Use RANK or DENSE_RANK instead if tied salaries should all be included. Common mistakes: filtering on the window function in the same SELECT, which is not allowed, and forgetting PARTITION BY so the ranking is global.

    sql
    SELECT name, dept_id, salary
    FROM (SELECT name, dept_id, salary,
                 ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC, id) AS rn
          FROM employees) t
    WHERE rn <= 2
    ORDER BY dept_id, rn;
  11. 11

    SQL: count customers per country after standardising messy labels such as ' india ', 'IN' and 'Bharat'. Table customers(id, country).

    medium

    Clean the value inside a CASE expression using TRIM and UPPER, map known variants to one label, and group by the cleaned expression. Anything unrecognised keeps a trimmed version of its original text. O(n) work for the scan. Common mistakes: grouping by the raw column, which leaves the variants separate, and forgetting to trim so that ' India' and 'India' differ.

    sql
    SELECT CASE WHEN UPPER(TRIM(country)) IN ('IN', 'INDIA', 'BHARAT') THEN 'India'
                ELSE TRIM(country) END AS cleaned_country,
           COUNT(*) AS customers
    FROM customers
    GROUP BY CASE WHEN UPPER(TRIM(country)) IN ('IN', 'INDIA', 'BHARAT') THEN 'India'
                  ELSE TRIM(country) END
    ORDER BY cleaned_country;
  12. 12

    SQL: delete duplicate contact rows, keeping the lowest id for each email. Table contacts(id, email).

    hard

    Delete rows whose id is not the minimum id of its email group. The subquery finds the survivors with GROUP BY, and the outer DELETE removes everyone else. Some engines, such as MySQL, will not let you select from the table you are deleting from in the same statement, so wrap the subquery in a derived table there. Common mistakes: deleting before checking with a SELECT of the same condition, and deduplicating on a column that differs by case.

    sql
    DELETE FROM contacts
    WHERE id NOT IN (SELECT MIN(id) FROM contacts GROUP BY email);

Frequently asked questions

What does the EY technology test cover?

Third-party guides list programming multiple-choice questions and coding in Python, SQL or Java for the technology track, over roughly one to one and a half hours. Confirm the details on your own invitation.

Is the coding portion hard?

Guides describe it as easy to medium. The problems here follow that level and emphasise careful handling of messy input.

Which SQL topics matter most?

Joins, grouping with HAVING, window functions for ranking, CASE expressions and de-duplication. The four queries on this page cover that range.

How should I show my work in a timed test?

Name the edge cases in a comment, such as an empty list or unparseable value, and handle them visibly. Graders and later reviewers value code that shows it considered them.

Where do I confirm EY's process?

Use EY's own careers site at ey.com/en_in/careers and your invitation email. Descriptions elsewhere, including the ones cited here, are third-party.

Sources

Related guides

More in Company Interview Questions

See all in this section