Wells Fargo coding round questions with solutions
Last updated 2026-11-19
Wells Fargo technology assessments in India are commonly reported to include aptitude questions and coding problems at easy to medium level, with arrays, strings, stacks, trees and SQL. The ten problems below are practice in that style, mostly the fundamentals that decide an easy to medium test. They are not recalled questions.
Each has the approach, complexity, a common mistake and runnable Python and Java. For the interview rounds, see Wells Fargo interview questions.
| Style | Easy to medium arrays, stacks, trees, binary search, SQL |
|---|---|
| Languages here | Python, Java, SQL |
| Problems | 9 coding, 1 aptitude MCQ |
| Level | Easy to medium |
How to approach this set
At this difficulty the bar is correctness across all test cases within the time limit, not clever tricks. Write the simplest correct solution first, then check the constraints to decide whether it is fast enough.
Build a habit of testing three inputs before submitting: empty or minimal, typical, and large. For the aptitude section, practise unit conversions and word problems; see how to crack the aptitude test and how to crack an online assessment.
Wells Fargo coding round questions with solutions: questions with worked answers
1 Two sum: return the indices of two numbers that add up to a target.
easyStore each value's index in a hash map as you scan. For x, check whether target - x was seen; if so return the two indices, otherwise store x. Time O(n), space O(n). Check before inserting so an element is not paired with itself. Sorting and two pointers uses O(1) space but loses the original indices unless you keep them.
pythondef two_sum(a, target): seen = {} for i, x in enumerate(a): if target - x in seen: return [seen[target - x], i] seen[x] = i return []javaimport java.util.*; class Solution { static int[] twoSum(int[] a, int target) { Map<Integer, Integer> seen = new HashMap<>(); for (int i = 0; i < a.length; i++) { Integer j = seen.get(target - a[i]); if (j != null) return new int[]{j, i}; seen.put(a[i], i); } return new int[0]; } }2 Move all zeroes to the end while keeping the order of the other elements, in place.
easyKeep a write pointer for the next non-zero position. Scan the array; whenever you see a non-zero value, swap it with the write position and advance. Time O(n), space O(1), and the swap count is minimal when you only swap if the positions differ. Mistake: building a new list when the problem says in place.
pythondef move_zeroes(a): w = 0 for r in range(len(a)): if a[r] != 0: a[w], a[r] = a[r], a[w] w += 1javaclass Solution { static void moveZeroes(int[] a) { int w = 0; for (int r = 0; r < a.length; r++) if (a[r] != 0) { int t = a[w]; a[w++] = a[r]; a[r] = t; } } }3 Majority element: find the value that appears more than n/2 times.
mediumBoyer-Moore voting: keep a candidate and a counter. If the counter is zero, take the current value as the candidate; then add one if the value equals the candidate, subtract one otherwise. The majority element survives because it outnumbers all others combined. Time O(n), space O(1). The algorithm assumes a majority exists; if it might not, make a second pass to verify.
pythondef majority(a): cand, cnt = None, 0 for x in a: if cnt == 0: cand = x cnt += 1 if x == cand else -1 return candjavaclass Solution { static int majority(int[] a) { int cand = 0, cnt = 0; for (int x : a) { if (cnt == 0) cand = x; cnt += (x == cand) ? 1 : -1; } return cand; } }4 Missing number: an array of n distinct values from 0 to n has one missing. Find it.
easyThe sum of 0..n is n(n+1)/2; subtract the array sum to get the missing value. Time O(n), space O(1). XOR of all indices and values is an overflow-free alternative. Mistake: using n(n+1)/2 with the wrong n; the array has n elements but the range runs to n inclusive.
pythondef missing(a): n = len(a) return n * (n + 1) // 2 - sum(a)javaclass Solution { static int missing(int[] a) { int x = a.length; for (int i = 0; i < a.length; i++) x ^= i ^ a[i]; return x; } }5 Design a stack that returns its minimum in O(1).
mediumKeep a second stack of running minimums, pushing a new minimum entry each time a value is pushed (the smaller of the value and the current minimum). Pop from both together. All operations are O(1), space O(n). A common bug is pushing to the min stack only when the value is smaller, which then needs care with duplicates; pushing every time avoids it.
pythonclass MinStack: def __init__(self): self.s, self.m = [], [] def push(self, x): self.s.append(x) self.m.append(min(x, self.m[-1]) if self.m else x) def pop(self): self.m.pop() return self.s.pop() def get_min(self): return self.m[-1]javaimport java.util.*; class MinStack { private final Deque<Integer> s = new ArrayDeque<>(), m = new ArrayDeque<>(); void push(int x) { s.push(x); m.push(m.isEmpty() ? x : Math.min(x, m.peek())); } int pop() { m.pop(); return s.pop(); } int getMin() { return m.peek(); } }6 Maximum depth of a binary tree.
easyThe depth of a node is 1 plus the larger depth of its children, and an empty tree has depth 0. Recursion is O(n) time and O(h) stack space. For a very deep tree, use a level-order traversal and count levels to avoid stack overflow. Mistake: returning 1 for a null node, which adds an extra level.
pythondef max_depth(root): if root is None: return 0 return 1 + max(max_depth(root.left), max_depth(root.right))javaclass Solution { static class TreeNode { int val; TreeNode left, right; } static int maxDepth(TreeNode root) { if (root == null) return 0; return 1 + Math.max(maxDepth(root.left), maxDepth(root.right)); } }7 Find the first and last position of a target in a sorted array with duplicates, in O(log n).
mediumRun binary search twice: one finds the leftmost index with value >= target, and the other finds the leftmost index with value > target, minus one for the last position. If the first index is out of range or does not hold the target, return [-1, -1]. Time O(log n), space O(1). The mistake is stopping at the first match and scanning outwards, which is O(n) on many duplicates. See binary search interview questions.
pythondef search_range(a, t): def lower(x): lo, hi = 0, len(a) while lo < hi: mid = (lo + hi) // 2 if a[mid] < x: lo = mid + 1 else: hi = mid return lo l = lower(t) if l == len(a) or a[l] != t: return [-1, -1] return [l, lower(t + 1) - 1]javaclass Solution { static int lower(int[] a, int x) { int lo = 0, hi = a.length; while (lo < hi) { int mid = (lo + hi) / 2; if (a[mid] < x) lo = mid + 1; else hi = mid; } return lo; } static int[] searchRange(int[] a, int t) { int l = lower(a, t); if (l == a.length || a[l] != t) return new int[]{-1, -1}; return new int[]{l, lower(a, t + 1) - 1}; } }8 Climbing stairs: how many distinct ways to climb n stairs taking 1 or 2 steps?
easyThe ways to reach stair n are the ways to reach n-1 (then one step) plus n-2 (then two steps): a Fibonacci recurrence with ways(1) = 1 and ways(2) = 2. Iterate with two variables for O(n) time and O(1) space. Plain recursion without memoisation is exponential, which is the mistake the question is designed to catch.
pythondef climb(n): a, b = 1, 1 for _ in range(n - 1): a, b = b, a + b return bjavaclass Solution { static long climb(int n) { long a = 1, b = 1; for (int i = 1; i < n; i++) { long c = a + b; a = b; b = c; } return b; } }9 SQL: find email addresses that appear more than once in a Person table.
easyGroup by email and keep groups with a count above one. Use HAVING because the condition is on an aggregate. Mention that comparison may need to be case-insensitive, using LOWER(email), depending on the requirement. If you also need the rows, join the result back to the table.
sqlSELECT email FROM Person GROUP BY email HAVING COUNT(*) > 1;10 Aptitude MCQ: a train 150 m long passes a pole in 15 seconds. How long does it take to cross a platform 250 m long at the same speed?
easyThe speed is 150 m / 15 s = 10 m/s. To cross the platform the train must cover its own length plus the platform: 150 + 250 = 400 m, so the time is 400 / 10 = 40 seconds. Forgetting to add the train's own length gives 25 seconds, the usual wrong option. To convert, 10 m/s equals 36 km/h.
Frequently asked questions
How hard is the Wells Fargo coding test?
Candidates commonly describe easy to medium problems on core data structures and algorithms, with aptitude questions in some cycles.
Does the test include SQL?
Technology roles are reported to include SQL. Practise joins, grouping and HAVING.
Which language should I use?
A 2027 internship posting lists Java, C#, SQL and Python. Use whichever you are most fluent in on the platform.
Are these the real questions?
No. They are original practice problems in the style of the topics the round commonly covers.
Related guides
More in Company Interview Questions
- Wells Fargo interview questions with answers (technology roles)
- Wipro Coding Round Questions with Solutions
- Wipro Interview Questions for Freshers
- Workday Coding Round Questions With Solutions
- Workday Interview Questions and Answers
- Zensar Coding Round Questions with Solutions
- Zensar Interview Questions for Freshers
- Zepto Coding Round Questions with Solutions
- Zepto Interview Questions and Answers
- Zerodha Coding Round Questions With Solutions
- Zerodha Interview Questions and Answers
- Zoho Coding Round Questions with Solutions