โ† Back to all recaps

๐Ÿšจ Microsoft 2026 Codility OA Leaked! 110 Minutes for 2 Problems โ€“ Why Are So Many Failing Despite It Looking Simple?

3 min read

Recently, Microsoft's Codility OA has been widely distributed.

Many candidates' first reaction after seeing the problems: "Easy! This is just DP/Greedy!"

Don't be overconfident.

If you treat them as ordinary algorithm problems, even with Bug-Free code, you'll likely get rejected.

Our oavoservice team obtained the actual problems immediately and discovered countless hidden traps related to Engineering Judgment.

๐Ÿ” Why Are Microsoft Codility Problems "Tricky"?

Microsoft doesn't favor LeetCode Hard problems like Google/Meta, but it has a more annoying characteristic:

โœ… Long problem descriptions with complex business scenarios
โœ… Requires manual input/output handling
โŒ Extremely tricky edge cases
โŒ Slight deviation in DP state definition = complete failure

Moreover, Codility platform features:

  • No interactive debugger
  • Can only see which test cases failed after submission
  • If TLE occurs, no way to know which case timed out

This "blind coding" mode severely tests your mental resilience.

Yesterday, one of our UIUC students spent 40 minutes on the first problem, only to find 60% pass rate after submission. He panicked immediately. Without our senior mentor's real-time voice guidance: "Stay calm, there's an issue with your DP state transition, redefine the states!", he probably couldn't have finished the second problem.

Final result? 110 minutes, 2 problems, all passed. Secured the interview invitation.

Let me break down these hot problems today and show you where the traps are.

๐Ÿ’ป Problem 1: Domino Sequence

๐Ÿ” Problem Core

Given an array A of length 2*N, representing N dominoes. Each domino consists of two numbers:

  • The K-th domino's left and right numbers are A[2*K] and A[2*K+1] respectively

Correct domino sequence: Adjacent dominoes must have the same number on their touching parts.

Problem requirement: What's the minimum number of dominoes to remove so the remaining ones form a correct sequence?

Constraints:

  • No reordering or rotating dominoes allowed
  • N range: [1..50,000]
  • Each element range: [1..6]

Example Analysis

Example 1:

A = [2, 4, 1, 3, 4, 6, 2, 4, 1, 6]
Dominoes: (2,4), (1,3), (4,6), (2,4), (1,6)
  • (2,4) and (1,3): right 4 != left 1, cannot connect
  • (2,4) and (4,6): right 4 == left 4, can connect!
  • Optimal solution: keep (2,4), (4,6), remove other 3

Answer: 3

๐Ÿคฏ Why Are So Many People Failing This?

Most people's first reactions:

โŒ "Isn't this just longest consecutive subsequence?"
โŒ "Use greedy, connect whenever possible!"
โŒ "Brute force enumerate all possibilities!"

Then they write increasingly messy code and realize they can't handle:

  1. How to define "connectable"?
  2. How to handle multiple possible starting points?
  3. How to ensure finding the global optimal solution?

โœ… Correct Engineering Mindset

This is a "Longest Increasing Subsequence variant + DP" problem.

Key Insight

This is not "greedy", but "dynamic programming"!

  • Each domino can serve as a starting point
  • For each domino, find all previous connectable dominoes
  • State transition: dp[i] = max(dp[j] + 1), where j < i and domino j's right equals domino i's left

๐Ÿ’ฃ Hidden Traps

Trap 1: Array Index Conversion

# Wrong approach
left = A[i]  # โŒ What is this?

# Correct approach
left = A[2*i]      # i-th domino's left
right = A[2*i + 1]  # i-th domino's right

Trap 2: Edge Cases

  • Only 1 domino: answer is 0 (no removal needed)
  • All dominoes disconnected: answer is N-1 (keep any 1)

Trap 3: DP Initialization

  • Each domino forms a sequence of length 1 alone
  • Cannot initialize to 0

๐ŸŽฏ Perfect Implementation (Python)

def solution(A):
    if len(A) == 0:
        return 0
    
    n = len(A) // 2
    if n == 1:
        return 0
    
    # Build domino list
    dominoes = []
    for i in range(n):
        left = A[2 * i]
        right = A[2 * i + 1]
        dominoes.append((left, right))
    
    # DP: dp[i] represents longest sequence ending at i-th domino
    dp = [1] * n
    
    for i in range(1, n):
        for j in range(i):
            # If j-th domino's right equals i-th domino's left
            if dominoes[j][1] == dominoes[i][0]:
                dp[i] = max(dp[i], dp[j] + 1)
    
    # Longest sequence length
    max_keep = max(dp)
    
    # Number to remove
    return n - max_keep

โšก๏ธ Time Complexity Optimization

The above solution is O(nยฒ), which might TLE for N=50,000.

Optimization idea: Use HashMap to record longest sequence for each right value

def solution(A):
    if len(A) == 0:
        return 0
    
    n = len(A) // 2
    if n == 1:
        return 0
    
    # HashMap: right_value -> max_length
    max_len = {}
    overall_max = 1
    
    for i in range(n):
        left = A[2 * i]
        right = A[2 * i + 1]
        
        # Find longest sequence connectable to current domino's left
        current_len = max_len.get(left, 0) + 1
        
        # Update longest sequence ending with right
        max_len[right] = max(max_len.get(right, 0), current_len)
        
        overall_max = max(overall_max, current_len)
    
    return n - overall_max

Time Complexity: O(n)
Space Complexity: O(1) (since domino numbers only 1-6)

๐Ÿ”ข Problem 2: Maximum Sum of Three Non-Adjacent Elements

๐Ÿ” Problem Core

Given integer array A, select exactly 3 non-adjacent elements to maximize their sum.

Non-adjacent definition: The three element indices must satisfy any two indices differ by > 1.

Constraints:

  • N range: [5..100,000]
  • Element range: [-100,000,000..100,000,000]

Example Analysis

Example 1:

A = [8, -4, -7, -5, -5, -4, 8, 8]
  • Positions 0, 3, 6: 8 + (-5) + 8 = 11
  • Positions 0, 5, 7: 8 + (-4) + 8 = 12 โœ… Optimal
  • Positions 0, 6, 7: 8 + 8 + 8 = 24, but 6 and 7 are adjacent โŒ

Answer: 12

Example 2:

A = [-2, -8, 1, 5, -8, 4, 7, 6]
  • Positions 3, 5, 7: 5 + 4 + 6 = 15 โœ…

Answer: 15

Example 3 (negative case):

A = [-3, 0, -6, -7, -9, -5, -2, -6]
  • Positions 1, 3, 6: 0 + (-7) + (-2) = -9 โœ…

Answer: -9

๐Ÿคฏ Hidden Killer: Why Do 90% Fail?

Seemingly simple problem, actually has three fatal traps:

Trap 1: Brute Force Will TLE

# โŒ This will definitely fail
max_sum = float('-inf')
for i in range(n):
    for j in range(i+2, n):
        for k in range(j+2, n):
            max_sum = max(max_sum, A[i] + A[j] + A[k])

Time Complexity: O(nยณ), for N=100,000 will definitely timeout.

Trap 2: Greedy Selection of 3 Largest Will Fail

# โŒ Wrong approach
sorted_indices = sorted(range(n), key=lambda i: A[i], reverse=True)
# Then try to find 3 non-adjacent ones?

Counter example:

A = [10, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 8]
  • Largest 3: 10, 9, 8
  • But positions: 0, 6, 12
  • 0 and 6 differ by 6 > 1, 6 and 12 differ by 6 > 1 โœ…
  • Looks feasible? But what if [10, 1, 9, 1, 8]?

Greedy completely fails with negative numbers!

Trap 3: Unclear DP State Definition

Many want to use DP but don't know how to define states:

# โŒ Wrong state
dp[i] = "max sum of first i elements"  # How many selected?

โœ… Correct Engineering Mindset: Enumerate Middle Element + Preprocessing

Core Insight

Fix the middle element, problem becomes simple!

  1. Enumerate the second element's position j (the middle one)
  2. Find maximum in [0, j-2] (first element)
  3. Find maximum in [j+2, n-1] (third element)

Key optimization: Preprocess prefix/suffix maximum values

๐Ÿ’ฃ Most Common Pitfall

Edge cases:

  • Array length must be at least 5 (3 elements + 2 gaps)
  • Middle element range: [2, n-3]

Negative number handling:

  • Cannot skip negative numbers! Even if all negative, must select 3

๐ŸŽฏ Perfect Implementation (Python)

def solution(A):
    n = len(A)
    
    # Boundary check
    if n < 5:
        return float('-inf')  # No solution possible
    
    # Preprocessing: prefix_max[i] represents max of [0, i]
    prefix_max = [float('-inf')] * n
    prefix_max[0] = A[0]
    for i in range(1, n):
        prefix_max[i] = max(prefix_max[i-1], A[i])
    
    # Preprocessing: suffix_max[i] represents max of [i, n-1]
    suffix_max = [float('-inf')] * n
    suffix_max[n-1] = A[n-1]
    for i in range(n-2, -1, -1):
        suffix_max[i] = max(suffix_max[i+1], A[i])
    
    # Enumerate middle element
    max_sum = float('-inf')
    for j in range(2, n-2):
        # First element from [0, j-2]
        first = prefix_max[j-2]
        # Third element from [j+2, n-1]
        third = suffix_max[j+2]
        
        current_sum = first + A[j] + third
        max_sum = max(max_sum, current_sum)
    
    return max_sum

Time Complexity: O(n)
Space Complexity: O(n)

๐Ÿ’ก Reality Check: Microsoft Codility OA Is Really Not Suitable for Solo Attempts

Microsoft SDE TC (North America):

New Grad: $160k โ€“ $180k
SDE II: $200k โ€“ $250k

Yet the brutal reality of Codility OA:

โŒ Must handle input/output yourself
โŒ No interactive debugging
โŒ One edge case error = complete failure
โŒ One chance, might wait half a year

What we do at oavoservice is simple:

โœ… You write the code
โœ… Someone monitors state definitions
โœ… Someone monitors edge cases
โœ… Someone monitors time complexity
โœ… Stop you before TLE / going wrong

It's not that you can't do it, it's that going alone carries too much risk.

๐Ÿš€ oavoservice: Your Perfect Score Expert

Facing Microsoft's engineering-heavy, detail-layered Codility OA, you need more than just answers โ€“ you need a professional technical team supporting you.

We provide:

โœ… Full Codility platform coverage: Familiar with platform characteristics, avoid hidden traps
โœ… Production-Level Code: Industrial-grade standards, not leetcode style
โœ… Real-time voice guidance: Senior engineers guide you during OA
โœ… Perfect score guarantee: No pass, no fee โ€“ we're confident in our expertise

Don't let one DP state transition or edge case block your path to a $200k Offer.

We consistently provide professional online assessment services for major tech companies like Microsoft, Google, and Amazon, guaranteeing perfect scores.

๐Ÿ‘‰ Add WeChat now: Coding0201

Secure your Microsoft interview opportunity!


่”็ณปๆ–นๅผ

Email: [email protected] Telegram: @OAVOProxy