Autocoder

Intuit Coding Round Questions with Solutions in Python and Java

Last updated 2026-11-19

Intuit's online assessment is reported to combine data structures, SQL and scripting questions. These ten problems focus on the data structure and algorithm side, with profit optimisation and dynamic programming that suit a company working on financial software.

Solve each yourself first, then compare with the worked Python and Java solutions, which include complexity and the mistakes to avoid.

Problems10, easy to hard
LanguagesPython and Java
PatternsStock DP, coin change, monotonic stack, prefix sums
Reported testOnline, around 90 minutes in one 2021 account

What these problems are modelled on

Candidate reports describe an Intuit online assessment of three to five data structures, SQL or scripting questions, with one 2021 account naming HackerEarth and four problems in about 90 minutes. Since Intuit builds money and tax software, the practice set below leans on profit and cost optimisation, dynamic programming and array scans that echo financial calculations. These are practice problems, not real test content.

For conceptual and behavioural preparation see Intuit interview questions.

Mistakes in optimisation problems

Hiring status

Intuit has no sourced hiring statements in the records used for this site. Check Intuit's own careers site, jobs.intuit.com, for current roles and any assessment dates.

Intuit Coding Round Questions with Solutions in Python and Java: questions with worked answers

  1. 1

    Best Time to Buy and Sell Stock: one transaction.

    easy

    Scan once keeping the minimum price so far and the best profit if you sell today. Time O(n), space O(1). Mistake: using two nested loops (O(n squared)), or buying after selling because you tracked the maximum instead of the minimum before the current index.

    python
    def max_profit(p):
        lo, best = float('inf'), 0
        for x in p:
            lo = min(lo, x)
            best = max(best, x - lo)
        return best
    java
    class Solution {
        int maxProfit(int[] p) {
            int lo = Integer.MAX_VALUE, best = 0;
            for (int x : p) { lo = Math.min(lo, x); best = Math.max(best, x - lo); }
            return best;
        }
    }
  2. 2

    Best Time to Buy and Sell Stock II: unlimited transactions.

    easy

    Greedy: add every positive day-to-day price increase. This equals buying at every valley and selling at every peak. Time O(n), space O(1). Mistake: trying to find peaks and valleys explicitly with off-by-one errors, when summing positive differences is simpler and just as correct.

    python
    def max_profit_ii(p):
        return sum(max(0, p[i] - p[i-1]) for i in range(1, len(p)))
    java
    class Solution {
        int maxProfit(int[] p) {
            int s = 0;
            for (int i = 1; i < p.length; i++) s += Math.max(0, p[i] - p[i - 1]);
            return s;
        }
    }
  3. 3

    Best Time to Buy and Sell Stock with Cooldown.

    hard

    State machine DP with three values: held (own a stock), sold (just sold today, so tomorrow is cooldown) and rest (no stock, free to buy). Update each day: held = max(held, rest - price), sold = held_prev + price, rest = max(rest, sold_prev). The answer is the maximum of sold and rest on the last day. Time O(n), space O(1). Mistake: updating states in place with new values instead of the previous day's.

    python
    def max_profit_cooldown(p):
        held, sold, rest = float('-inf'), 0, 0
        for x in p:
            prev_sold = sold
            sold = held + x
            held = max(held, rest - x)
            rest = max(rest, prev_sold)
        return max(sold, rest)
    java
    class Solution {
        int maxProfit(int[] p) {
            int held = Integer.MIN_VALUE, sold = 0, rest = 0;
            for (int x : p) {
                int prevSold = sold;
                sold = held + x;
                held = Math.max(held, rest - x);
                rest = Math.max(rest, prevSold);
            }
            return Math.max(sold, rest);
        }
    }
  4. 4

    Coin Change: fewest coins to make an amount, or -1.

    medium

    Bottom-up DP: dp[a] is the fewest coins for amount a, with dp[0] = 0 and dp[a] = 1 + min(dp[a - c]) over coins c not exceeding a. Time O(amount x coins), space O(amount). Mistake: greedy largest-first, which fails for coins like [1, 3, 4] and amount 6, and initialising dp with 0 rather than infinity. See dynamic programming interview questions.

    python
    def coin_change(coins, amount):
        INF = amount + 1
        dp = [0] + [INF] * amount
        for a in range(1, amount + 1):
            for c in coins:
                if c <= a: dp[a] = min(dp[a], dp[a - c] + 1)
        return dp[amount] if dp[amount] != INF else -1
    java
    import java.util.*;
    class Solution {
        int coinChange(int[] coins, int amount) {
            int[] dp = new int[amount + 1];
            Arrays.fill(dp, amount + 1);
            dp[0] = 0;
            for (int a = 1; a <= amount; a++)
                for (int c : coins) if (c <= a) dp[a] = Math.min(dp[a], dp[a - c] + 1);
            return dp[amount] > amount ? -1 : dp[amount];
        }
    }
  5. 5

    House Robber II: houses in a circle, cannot rob adjacent ones.

    medium

    Because the first and last houses are adjacent, the answer is the larger of the best for houses 0 to n - 2 and for houses 1 to n - 1, each solved with the linear house-robber DP. Handle a single house separately. Time O(n), space O(1). Mistake: applying the linear solution once to the whole array.

    python
    def rob(nums):
        def line(a):
            prev = cur = 0
            for x in a: prev, cur = cur, max(cur, prev + x)
            return cur
        if len(nums) == 1: return nums[0]
        return max(line(nums[:-1]), line(nums[1:]))
    java
    class Solution {
        int rob(int[] a) {
            if (a.length == 1) return a[0];
            return Math.max(line(a, 0, a.length - 2), line(a, 1, a.length - 1));
        }
        private int line(int[] a, int lo, int hi) {
            int prev = 0, cur = 0;
            for (int i = lo; i <= hi; i++) { int t = Math.max(cur, prev + a[i]); prev = cur; cur = t; }
            return cur;
        }
    }
  6. 6

    Minimum Path Sum from top-left to bottom-right moving only right or down.

    medium

    dp[i][j] is the cell value plus the smaller of the best sums from above and from the left. Reuse a single row to keep space O(columns). Time O(rows x columns). Mistake: forgetting that the first row and first column have only one possible predecessor.

    python
    def min_path_sum(g):
        R, C = len(g), len(g[0])
        dp = [float('inf')] * C
        dp[0] = 0
        for i in range(R):
            dp[0] += g[i][0]
            for j in range(1, C):
                dp[j] = g[i][j] + min(dp[j], dp[j - 1])
        return dp[-1]
    java
    import java.util.*;
    class Solution {
        int minPathSum(int[][] g) {
            int R = g.length, C = g[0].length;
            int[] dp = new int[C];
            Arrays.fill(dp, Integer.MAX_VALUE);
            dp[0] = 0;
            for (int i = 0; i < R; i++) {
                dp[0] += g[i][0];
                for (int j = 1; j < C; j++) dp[j] = g[i][j] + Math.min(dp[j], dp[j - 1]);
            }
            return dp[C - 1];
        }
    }
  7. 7

    Daily Temperatures: days until a warmer day for each day.

    medium

    Use a monotonic decreasing stack of indices. For each day, while the stack's top has a lower temperature, pop it and set its answer to the index difference; then push the current day. Each index is pushed and popped once, so time is O(n), space O(n). Mistake: a nested loop scanning forward for every day, which is O(n squared) in the worst case.

    python
    def daily_temperatures(t):
        ans, st = [0] * len(t), []
        for i, x in enumerate(t):
            while st and t[st[-1]] < x:
                j = st.pop(); ans[j] = i - j
            st.append(i)
        return ans
    java
    import java.util.*;
    class Solution {
        int[] dailyTemperatures(int[] t) {
            int[] ans = new int[t.length];
            Deque<Integer> st = new ArrayDeque<>();
            for (int i = 0; i < t.length; i++) {
                while (!st.isEmpty() && t[st.peek()] < t[i]) { int j = st.pop(); ans[j] = i - j; }
                st.push(i);
            }
            return ans;
        }
    }
  8. 8

    Excel Sheet Column Title: convert a column number to its letters (1 is A, 27 is AA).

    easy

    This is bijective base 26 with no zero digit, so subtract one before each division: n -= 1, then the letter is chr(65 + n % 26) and n //= 26. Build letters in reverse. Time O(log n). Mistake: using plain base 26, which gives a wrong answer at 26 (Z) and 52 (AZ).

    python
    def column_title(n):
        out = []
        while n:
            n -= 1
            out.append(chr(65 + n % 26))
            n //= 26
        return ''.join(reversed(out))
    java
    class Solution {
        String columnTitle(int n) {
            StringBuilder sb = new StringBuilder();
            while (n > 0) { n--; sb.append((char) ('A' + n % 26)); n /= 26; }
            return sb.reverse().toString();
        }
    }
  9. 9

    Container With Most Water: maximum area between two lines.

    medium

    Two pointers at both ends; the area is the shorter height times the distance. Move the pointer at the shorter line inward, because moving the taller one cannot increase the area (width shrinks and the height is still capped by the short line). Time O(n), space O(1). Mistake: moving the taller line, or trying all pairs in O(n squared).

    python
    def max_area(h):
        l, r, best = 0, len(h) - 1, 0
        while l < r:
            best = max(best, min(h[l], h[r]) * (r - l))
            if h[l] < h[r]: l += 1
            else: r -= 1
        return best
    java
    class Solution {
        int maxArea(int[] h) {
            int l = 0, r = h.length - 1, best = 0;
            while (l < r) {
                best = Math.max(best, Math.min(h[l], h[r]) * (r - l));
                if (h[l] < h[r]) l++; else r--;
            }
            return best;
        }
    }
  10. 10

    Subarray Sums Divisible by K: count subarrays whose sum is a multiple of k.

    medium

    Use prefix sums modulo k. Two prefix sums with the same remainder mean the subarray between them has a sum divisible by k. Count with a map of remainder frequencies, seeded with remainder 0 once, normalising negatives with ((s % k) + k) % k. Time O(n), space O(k). Mistake: forgetting that Java and C++ remainders can be negative.

    python
    def subarrays_div_by_k(a, k):
        cnt, s, res = {0: 1}, 0, 0
        for x in a:
            s = (s + x) % k
            res += cnt.get(s, 0)
            cnt[s] = cnt.get(s, 0) + 1
        return res
    java
    import java.util.*;
    class Solution {
        int subarraysDivByK(int[] a, int k) {
            int[] cnt = new int[k];
            cnt[0] = 1;
            int s = 0, res = 0;
            for (int x : a) {
                s = ((s + x) % k + k) % k;
                res += cnt[s]++;
            }
            return res;
        }
    }

Frequently asked questions

How difficult are Intuit coding questions?

Candidate reports describe a mix of easy and medium data structure problems. Practise DP and arrays thoroughly.

Is SQL part of the Intuit assessment?

Reports mention SQL and scripting alongside data structures, so practise SQL separately.

Which language should I use?

Use the one the platform allows and you code fastest in. Python and Java are both given here.

Sources

Related guides

More in Company Interview Questions

See all in this section