← LinkedIn Interview Insights

LinkedIn·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026Remote

Summary

LinkedIn coding screen for a software engineer role, focused entirely on array problems with a follow-up twist I didn't see coming. The circular wrap-around variant is what tripped me up.

Questions Asked (2)

Q1

Given a binary array, find the maximum number of consecutive 1s in the array.

Algorithms & Data Structures
Author's notes

Pretty standard stuff, single pass tracking a running count and a max.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and edge cases, then propose a single-pass linear scan that tracks the current run of 1s and updates the maximum. Discuss time and space complexity, and offer to code the solution with clear variable names and tests.

Pro tip: Mention that this is a classic sliding window/counting problem and that the same pattern extends to finding the longest subarray with at most K zeros or ones, showing you understand the underlying technique.

1. Clarify the problem

Confirm the input is a binary array (only 0s and 1s) and that we need the length of the longest contiguous subarray of 1s. Ask about edge cases like empty array or all 1s.

2. Outline the approach

Propose a single-pass scan: maintain a current count of consecutive 1s and a maximum count. Reset current count to 0 when encountering a 0, and update maximum when current exceeds it.

3. Analyze complexity

State that the algorithm runs in O(n) time and O(1) space, which is optimal since every element must be examined at least once.

4. Code the solution

Write clean code with meaningful variable names (e.g., maxStreak, currentStreak). Handle edge cases such as empty array by returning 0.

5. Test and verify

Walk through a few test cases: [1,1,0,1,1,1] returns 3, [0,0,0] returns 0, [1,1,1,1] returns 4. Mention that the solution is robust.

Key Points to Mention

  • Single-pass linear scan with O(n) time and O(1) space
  • Maintaining current streak and maximum streak variables
  • Resetting current streak on encountering a 0
  • Handling edge cases: empty array, all 0s, all 1s
  • The pattern generalizes to sliding window problems (e.g., longest subarray with at most K zeros)
  • Code clarity and testing with examples

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

Q2

Follow-up: now assume the array is circular, meaning the last element wraps around to the first. Find the maximum consecutive run of 1s, which may span the wrap-around point.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where I fumbled.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify that the circular array allows a run to wrap around, so the maximum run is either entirely within the array or spans the boundary. Compute the maximum run without wrap using a linear scan, and also compute the total number of 1s; if the array is all 1s, the answer is n, otherwise the maximum wrap-around run is the sum of the leading 1s and trailing 1s. Return the maximum of these two values.

Pro tip: Mention edge cases upfront, like all 1s or no 1s, and note that the wrap-around run can only be formed by the suffix and prefix, not by concatenating arbitrary segments. This shows attention to detail and avoids common pitfalls.

1. Clarify the problem and edge cases

Confirm that the array is circular and a run can wrap around. Discuss edge cases: all 1s, no 1s, and arrays with only one 1.

2. Compute maximum run without wrap

Perform a linear scan to find the longest consecutive sequence of 1s in the non-circular array. Keep track of the current run and the maximum run.

3. Compute total number of 1s and check if all are 1s

Count the total number of 1s. If it equals the array length, the answer is n. Otherwise, proceed to compute the wrap-around run.

4. Compute wrap-around run

Find the length of the prefix of 1s and the suffix of 1s. The maximum wrap-around run is the sum of these two lengths, but only if there is at least one 0 in the array (otherwise it would be the whole array).

5. Return the maximum

Return the maximum of the non-wrap run and the wrap-around run. Discuss time and space complexity: O(n) time, O(1) space.

Key Points to Mention

  • Time complexity: O(n) with a single pass or two passes.
  • Space complexity: O(1) extra space.
  • Edge case: all 1s -> answer is n.
  • Edge case: no 1s -> answer is 0.
  • The wrap-around run is formed by suffix + prefix, but only if there is at least one 0.
  • Alternative approach: duplicate the array and find the longest run of 1s, but cap at n to avoid counting more than n elements.

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