As reported: Microsoft SWE 2 (hiring drive, Oct 2025), round 1: two DSA questions — exactly LeetCode Max Consecutive Ones III and Rotting Oranges.
Given a binary array nums and an integer k, return the maximum number of consecutive 1s in the array if you can flip at most k 0s.
This is LeetCode 1004 — Max Consecutive Ones III.
Example 1
nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2 -> 6
Example 2
nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3 -> 10
Constraints: 1 ≤ nums.length ≤ 10^5; nums[i] is 0 or 1; 0 ≤ k ≤ nums.length.
Code runner format: one JSON value per line: nums, k (LeetCode's test-case format). Implement longestOnes(nums, k); the harness prints the result.