Autocoder

Atlassian Coding Round Questions with Solutions in Python and Java

Last updated 2026-11-19

Atlassian's coding interviews judge code quality, testing and adaptability, so the problems tend to be small, practical designs rather than puzzles. These ten cover tries, calendars, iterators, expression parsing and hierarchical data.

Write your own solution with tests first, then compare with the worked Python and Java versions.

Problems10, easy to hard
LanguagesPython and Java
PatternsTries, intervals, iterators, small data structures
Interview format, per Atlassian60 minutes, own IDE, screen-shared

The practical, tested style

Atlassian's guides say its coding interviews are 60 minutes, screen-shared in your own IDE, and assess code quality, testing, conceptual thinking, communication and adaptability. The problems below are the kind of practical building blocks, such as autocomplete, calendars, iterators, version comparison and small data structures, that suit that format: easy to state, with room for clean design, tests and a follow-up that changes a requirement. They are practice problems, not real interview content.

For design and behavioural preparation see Atlassian interview questions.

Habits that earn marks beyond a correct answer

Hiring status

For current Atlassian roles, see Atlassian hiring and apply through atlassian.com/company/careers. An Atlassian posting lists a Software Engineering Intern, 2027 Intern India role in Bengaluru, but confirm eligibility on that page.

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

  1. 1

    Autocomplete with a Trie: return up to three words with a given prefix.

    medium

    Build a trie from the dictionary, walk to the prefix node, then DFS from there collecting words in alphabetical order until you have three. Insert is O(L), lookup O(P + output). Mistake: scanning the entire word list per query (O(N x L)), and returning matches in arbitrary order when sorted output is expected.

    python
    class Trie:
        def __init__(self):
            self.kids, self.end = {}, False
        def insert(self, w):
            n = self
            for c in w:
                n = n.kids.setdefault(c, Trie())
            n.end = True
        def suggest(self, prefix, limit=3):
            n = self
            for c in prefix:
                if c not in n.kids: return []
                n = n.kids[c]
            out = []
            def dfs(node, path):
                if len(out) == limit: return
                if node.end: out.append(prefix + path)
                for c in sorted(node.kids): dfs(node.kids[c], path + c)
            dfs(n, '')
            return out
    java
    import java.util.*;
    class Trie {
        private final TreeMap<Character, Trie> kids = new TreeMap<>();
        private boolean end;
        void insert(String w) {
            Trie n = this;
            for (char c : w.toCharArray()) n = n.kids.computeIfAbsent(c, k -> new Trie());
            n.end = true;
        }
        List<String> suggest(String prefix, int limit) {
            Trie n = this;
            for (char c : prefix.toCharArray()) { n = n.kids.get(c); if (n == null) return List.of(); }
            List<String> out = new ArrayList<>();
            n.dfs(new StringBuilder(prefix), out, limit);
            return out;
        }
        private void dfs(StringBuilder path, List<String> out, int limit) {
            if (out.size() == limit) return;
            if (end) out.add(path.toString());
            for (var e : kids.entrySet()) {
                path.append(e.getKey()); e.getValue().dfs(path, out, limit); path.setLength(path.length() - 1);
            }
        }
    }
  2. 2

    Compare Version Numbers such as '1.02' and '1.2.0'.

    easy

    Split on dots and compare numeric values part by part, treating missing parts as zero. Return -1, 0 or 1 at the first difference. Time O(n). Mistake: comparing the parts as strings, so '10' sorts before '9', and ignoring leading zeros or unequal lengths.

    python
    def compare_version(a, b):
        x, y = a.split('.'), b.split('.')
        for i in range(max(len(x), len(y))):
            p = int(x[i]) if i < len(x) else 0
            q = int(y[i]) if i < len(y) else 0
            if p != q: return -1 if p < q else 1
        return 0
    java
    class Solution {
        int compareVersion(String a, String b) {
            String[] x = a.split("\\."), y = b.split("\\.");
            for (int i = 0; i < Math.max(x.length, y.length); i++) {
                int p = i < x.length ? Integer.parseInt(x[i]) : 0, q = i < y.length ? Integer.parseInt(y[i]) : 0;
                if (p != q) return p < q ? -1 : 1;
            }
            return 0;
        }
    }
  3. 3

    My Calendar I: book an event only if it does not overlap an existing one.

    medium

    Half-open intervals [start, end) overlap if start < other_end and other_start < end. Keep bookings sorted and binary-search the neighbours, or use a TreeMap and check the floor and ceiling entries. Booking is O(log n) with a sorted structure and O(n) with a plain list scan. Mistake: treating touching events like [10,20) and [20,30) as overlapping.

    python
    import bisect
    class MyCalendar:
        def __init__(self):
            self.starts, self.ends = [], []
        def book(self, s, e):
            i = bisect.bisect_left(self.starts, s)
            if i > 0 and self.ends[i - 1] > s: return False
            if i < len(self.starts) and self.starts[i] < e: return False
            self.starts.insert(i, s); self.ends.insert(i, e)
            return True
    java
    import java.util.*;
    class MyCalendar {
        private final TreeMap<Integer, Integer> m = new TreeMap<>();
        boolean book(int s, int e) {
            Integer lo = m.floorKey(s), hi = m.ceilingKey(s);
            if (lo != null && m.get(lo) > s) return false;
            if (hi != null && hi < e) return false;
            m.put(s, e);
            return true;
        }
    }
  4. 4

    Flatten Nested List Iterator.

    hard

    Use a stack of iterators or a stack of items in reverse. hasNext must prepare the next integer by unpacking lists on top of the stack until an integer is on top or the stack is empty; next returns it. Total time O(n) over all calls. Mistake: flattening everything in the constructor when the list is huge or lazily consumed, and not handling empty nested lists.

    python
    class NestedIterator:
        def __init__(self, nested):
            self.st = list(reversed(nested))
        def has_next(self):
            while self.st and isinstance(self.st[-1], list):
                self.st.extend(reversed(self.st.pop()))
            return bool(self.st)
        def next(self):
            self.has_next()
            return self.st.pop()
    java
    import java.util.*;
    class NestedIterator {
        private final Deque<Object> st = new ArrayDeque<>();
        NestedIterator(List<Object> nested) { for (int i = nested.size() - 1; i >= 0; i--) st.push(nested.get(i)); }
        @SuppressWarnings("unchecked")
        boolean hasNext() {
            while (!st.isEmpty() && st.peek() instanceof List) {
                List<Object> l = (List<Object>) st.pop();
                for (int i = l.size() - 1; i >= 0; i--) st.push(l.get(i));
            }
            return !st.isEmpty();
        }
        int next() { hasNext(); return (Integer) st.pop(); }
    }
  5. 5

    Lowest Common Ancestor in an employee hierarchy (an N-ary tree).

    medium

    Recurse: if the node is null or equals one of the targets, return it; collect results from all children; if two or more children return non-null the current node is the LCA, otherwise return the single non-null result. Time O(n), space O(h). Mistake: only handling binary trees by checking left and right, instead of iterating over a children list.

    python
    def lca(node, a, b):
        if node is None or node is a or node is b: return node
        found = [r for r in (lca(c, a, b) for c in node.children) if r]
        if len(found) >= 2: return node
        return found[0] if found else None
    java
    import java.util.*;
    class Emp { List<Emp> children = new ArrayList<>(); }
    class Solution {
        Emp lca(Emp node, Emp a, Emp b) {
            if (node == null || node == a || node == b) return node;
            Emp found = null; int cnt = 0;
            for (Emp c : node.children) {
                Emp r = lca(c, a, b);
                if (r != null) { cnt++; found = r; }
            }
            return cnt >= 2 ? node : found;
        }
    }
  6. 6

    Design Tic-Tac-Toe with O(1) work per move.

    medium

    Keep counters per row, per column and for both diagonals. A move adds +1 for player one and -1 for player two to the relevant counters; if any counter's absolute value reaches n, that player wins. Each move is O(1), space O(n). Mistake: scanning the whole board after every move, which is O(n) or O(n squared).

    python
    class TicTacToe:
        def __init__(self, n):
            self.n = n
            self.rows, self.cols = [0] * n, [0] * n
            self.diag = self.anti = 0
        def move(self, r, c, player):
            d = 1 if player == 1 else -1
            self.rows[r] += d; self.cols[c] += d
            if r == c: self.diag += d
            if r + c == self.n - 1: self.anti += d
            if self.n in (abs(self.rows[r]), abs(self.cols[c]), abs(self.diag), abs(self.anti)): return player
            return 0
    java
    class TicTacToe {
        private final int n; private final int[] rows, cols; private int diag, anti;
        TicTacToe(int n) { this.n = n; rows = new int[n]; cols = new int[n]; }
        int move(int r, int c, int player) {
            int d = player == 1 ? 1 : -1;
            rows[r] += d; cols[c] += d;
            if (r == c) diag += d;
            if (r + c == n - 1) anti += d;
            if (Math.abs(rows[r]) == n || Math.abs(cols[c]) == n || Math.abs(diag) == n || Math.abs(anti) == n) return player;
            return 0;
        }
    }
  7. 7

    Basic Calculator II: evaluate an expression with + - * / and no parentheses.

    medium

    Scan the string keeping the current number and the previous operator. When you reach an operator or the end, apply the previous operator: push the number for +, push its negative for -, and for * and / combine with the stack top. At the end sum the stack. Time O(n), space O(n). Mistake: ignoring operator precedence by evaluating left to right, and division of negatives (truncate toward zero).

    python
    def calculate(s):
        st, num, op = [], 0, '+'
        for i, ch in enumerate(s):
            if ch.isdigit(): num = num * 10 + int(ch)
            if ch in '+-*/' or i == len(s) - 1:
                if op == '+': st.append(num)
                elif op == '-': st.append(-num)
                elif op == '*': st.append(st.pop() * num)
                else: st.append(int(st.pop() / num))
                op, num = ch, 0
        return sum(st)
    java
    import java.util.*;
    class Solution {
        int calculate(String s) {
            Deque<Integer> st = new ArrayDeque<>();
            int num = 0; char op = '+';
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if (Character.isDigit(ch)) num = num * 10 + (ch - '0');
                if ((!Character.isDigit(ch) && ch != ' ') || i == s.length() - 1) {
                    if (op == '+') st.push(num);
                    else if (op == '-') st.push(-num);
                    else if (op == '*') st.push(st.pop() * num);
                    else st.push(st.pop() / num);
                    op = ch; num = 0;
                }
            }
            int sum = 0;
            for (int v : st) sum += v;
            return sum;
        }
    }
  8. 8

    Insert Delete GetRandom O(1).

    medium

    Keep a list of values and a map from value to its index in the list. Insert appends and records the index. Delete swaps the target with the last element, updates the moved element's index, pops the last and removes the key. GetRandom picks a random index in the list. All O(1) on average. Mistake: deleting from the middle of the list (O(n)) or forgetting to update the swapped element's index.

    python
    import random
    class RandomizedSet:
        def __init__(self):
            self.vals, self.idx = [], {}
        def insert(self, v):
            if v in self.idx: return False
            self.idx[v] = len(self.vals); self.vals.append(v)
            return True
        def remove(self, v):
            if v not in self.idx: return False
            i, last = self.idx.pop(v), self.vals.pop()
            if i < len(self.vals):
                self.vals[i] = last; self.idx[last] = i
            return True
        def get_random(self):
            return random.choice(self.vals)
    java
    import java.util.*;
    class RandomizedSet {
        private final List<Integer> vals = new ArrayList<>();
        private final Map<Integer, Integer> idx = new HashMap<>();
        private final Random rnd = new Random();
        boolean insert(int v) {
            if (idx.containsKey(v)) return false;
            idx.put(v, vals.size()); vals.add(v); return true;
        }
        boolean remove(int v) {
            Integer i = idx.remove(v);
            if (i == null) return false;
            int last = vals.remove(vals.size() - 1);
            if (i < vals.size()) { vals.set(i, last); idx.put(last, i); }
            return true;
        }
        int getRandom() { return vals.get(rnd.nextInt(vals.size())); }
    }
  9. 9

    Find Duplicate File in System: group files with identical content.

    medium

    Parse each directory line into file paths and contents, and group full paths in a hash map keyed by the content string. Report groups with two or more paths. Time O(total characters), space O(total characters). In practice you hash content to save memory, and compare size first, then partial hash, then full hash. Mistake: grouping by file name, not content.

    python
    from collections import defaultdict
    def find_duplicates(paths):
        g = defaultdict(list)
        for line in paths:
            parts = line.split()
            d = parts[0]
            for f in parts[1:]:
                name, content = f[:-1].split('(')
                g[content].append(d + '/' + name)
        return [v for v in g.values() if len(v) > 1]
    java
    import java.util.*;
    class Solution {
        List<List<String>> findDuplicates(String[] paths) {
            Map<String, List<String>> g = new HashMap<>();
            for (String line : paths) {
                String[] parts = line.split(" ");
                for (int i = 1; i < parts.length; i++) {
                    int p = parts[i].indexOf('(');
                    String content = parts[i].substring(p + 1, parts[i].length() - 1);
                    g.computeIfAbsent(content, k -> new ArrayList<>()).add(parts[0] + "/" + parts[i].substring(0, p));
                }
            }
            List<List<String>> res = new ArrayList<>();
            for (List<String> v : g.values()) if (v.size() > 1) res.add(v);
            return res;
        }
    }
  10. 10

    Snapshot Array: set values and take snapshots, then read an index at a past snapshot.

    hard

    For each index store a list of (snapshot id, value) pairs appended only when the value changes after a snapshot. A get at snapshot s binary-searches that index's list for the last entry with id at most s. Snap is O(1), set is O(1), get is O(log k). Mistake: copying the whole array on every snapshot, which is O(n) time and memory per snapshot.

    python
    import bisect
    class SnapshotArray:
        def __init__(self, n):
            self.h = [[(0, 0)] for _ in range(n)]
            self.sid = 0
        def set(self, i, v):
            if self.h[i][-1][0] == self.sid: self.h[i][-1] = (self.sid, v)
            else: self.h[i].append((self.sid, v))
        def snap(self):
            self.sid += 1
            return self.sid - 1
        def get(self, i, snap_id):
            j = bisect.bisect_right(self.h[i], (snap_id, float('inf'))) - 1
            return self.h[i][j][1]
    java
    import java.util.*;
    class SnapshotArray {
        private final List<int[]>[] h; private int sid = 0;
        @SuppressWarnings("unchecked")
        SnapshotArray(int n) {
            h = new List[n];
            for (int i = 0; i < n; i++) { h[i] = new ArrayList<>(); h[i].add(new int[]{0, 0}); }
        }
        void set(int i, int v) {
            List<int[]> l = h[i];
            if (l.get(l.size() - 1)[0] == sid) l.get(l.size() - 1)[1] = v; else l.add(new int[]{sid, v});
        }
        int snap() { return sid++; }
        int get(int i, int snapId) {
            List<int[]> l = h[i];
            int lo = 0, hi = l.size() - 1;
            while (lo < hi) { int m = (lo + hi + 1) >>> 1; if (l.get(m)[0] <= snapId) lo = m; else hi = m - 1; }
            return l.get(lo)[1];
        }
    }

Frequently asked questions

Does Atlassian care about tests in coding rounds?

Yes. Its interview guides list testing and code quality among the assessed areas of the coding interviews.

Which language should I use?

Use the language you are strongest in, in your own IDE. Python and Java are both given here.

Will the requirements change mid-interview?

Atlassian's guides list adaptability as an assessed trait, so expect follow-ups and keep your design flexible.

Sources

Related guides

More in Company Interview Questions

See all in this section