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 topics | Python, SQL, Java, programming MCQs |
|---|---|
| Difficulty here | Easy 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 Normalise an Indian mobile number typed in many styles to its ten digits, or reject it.
easyStrip 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.
pythonimport 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 Nonejavaclass 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 Convert date strings written in several formats to ISO yyyy-mm-dd.
mediumTry 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.
pythonfrom 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 Nonejavaimport 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 Replace missing readings in a column with the mean of the known ones.
easyCompute 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.
pythondef 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]javaclass 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 Flag outliers in a numeric column using the 1.5 x IQR rule.
mediumSort 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.
pythondef _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]javaimport 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 Keep only the most recent record for each customer id.
easyWalk 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.
pythondef 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()}javaimport 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 Compute the average amount per group, rounded to two decimals, from (group, amount) rows.
easyKeep 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.
pythondef 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())}javaimport 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 Run-length compress a string, so that aaabbc becomes a3b2c1.
easyWalk 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.
pythondef 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)javaclass 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 Flatten a list that contains lists nested to any depth.
mediumRecursion: 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.
pythondef flatten(items): out = [] for item in items: if isinstance(item, list): out.extend(flatten(item)) else: out.append(item) return outjavaimport 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 SQL: find the nth highest distinct salary. Table employees(id, name, salary).
mediumRank 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.
sqlSELECT salary FROM (SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS r FROM employees) ranked WHERE r = 3 GROUP BY salary;10 SQL: show the two highest-paid employees in every department. Table employees(id, name, dept_id, salary).
mediumNumber 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.
sqlSELECT 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 SQL: count customers per country after standardising messy labels such as ' india ', 'IN' and 'Bharat'. Table customers(id, country).
mediumClean 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.
sqlSELECT 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 SQL: delete duplicate contact rows, keeping the lowest id for each email. Table contacts(id, email).
hardDelete 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.
sqlDELETE 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
- 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
- Freshworks Interview Questions and Answers
- Goldman Sachs coding round questions with solutions
- Goldman Sachs interview questions with answers (engineering analyst)
- Google Coding Round Questions with Solutions in Python and Java