Your question is Solve Rotten Oranges Array. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In an Okta Workforce Identity Cloud access pipeline, a compromised session spreads to adjacent sessions over time. Given a grid, compute how many minutes are required for all fresh sessions to become compromised. Also analyze an activity array by finding the longest contiguous subarray containing at most k distinct values.
Implement solve_access_analysis(grid, nums, k) and return [minutes, longest_length].
For the grid, 0 represents an empty cell, 1 represents a fresh session, and 2 represents an initially compromised session. Each minute, every compromised cell changes its up, down, left, or right fresh neighbors to compromised. Return -1 if at least one fresh session can never be reached.
For the array, return the maximum length of a contiguous subarray containing no more than k distinct values. Return 0 when k is zero or the array is empty.
grid is a rectangular list of lists of integers and may be empty.nums is a list of integers.k is a nonnegative integer.[minutes, longest_length].def solve_access_analysis(grid, nums, k):