← Atlassian Interview Insights

Atlassian·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Atlassian ML Engineer interview with a coding round that included a classic string manipulation problem. Nothing too wild, but it's the kind of question that feels easy until you start second-guessing your cow-counting logic.

Questions Asked (1)

Q1

Given a secret number and a guess, return a hint string in the format 'xAyB' where x is the count of digits correct in both value and position (bulls), and y is the count of digits that appear in the secret but are in the wrong position (cows).

Algorithms & Data Structures
Author's notes

The bulls part is easy, just a single pass comparison.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a two-pass counting approach: first count bulls by comparing digits at the same index, then count cows by tracking the frequency of remaining digits in the secret and matching them with remaining guess digits. This avoids double-counting and runs in O(n) time with O(1) space (since digits are 0-9).

Pro tip: Clarify edge cases upfront, such as repeated digits and input length assumptions, and mention that the solution is O(n) time and O(1) space due to the fixed digit set. This shows attention to detail and efficiency.

1. Clarify requirements and edge cases

Ask about input format (strings or integers), length equality, and handling of repeated digits. Confirm that bulls take precedence over cows.

2. Count bulls in first pass

Iterate through both strings simultaneously and increment bulls when digits match at the same position. Mark these positions as used to avoid counting them as cows.

3. Count cows using frequency maps

For non-bull positions, count the frequency of each digit in the secret and in the guess. The number of cows is the sum of the minimum frequencies for each digit.

4. Format and return the hint

Construct the string in the format 'xAyB' using the counts of bulls and cows.

5. Analyze complexity and test

State that the algorithm runs in O(n) time and O(1) space (since digits are 0-9). Walk through a few test cases, including repeated digits.

Key Points to Mention

  • Two-pass approach to avoid double-counting bulls as cows
  • Use of frequency arrays or hash maps for counting cows
  • Time complexity O(n) and space complexity O(1) due to fixed digit set
  • Handling of repeated digits correctly (e.g., secret '1122', guess '2211' yields '0A4B')
  • Edge cases: empty strings, different lengths, non-digit characters (if applicable)
  • Clear variable naming and modular code structure

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.