Meta Online Assessment Questions on Soil Moisture Smoothing and Molecular Bonding
Question Details
The third question is a bit difficult, requiring the use of 2D prefix sums to optimize the calculation of the mean. You are an agricultural scientist working on precision farming technology. You are g
Full Details
The third question is a bit difficult, requiring the use of 2D prefix sums to optimize the calculation of the mean. You are an agricultural scientist working on precision farming technology. You are given a two-dimensional matrix of integers moistureGrid representing soil moisture levels across a field, with moistureGrid[i][j] containing an integer from 0 to 255 to represent the moisture level of a soil cell at coordinate (i, j). You are also given a non-negative integer parameter smoothingRadius Your task is to apply a moisture smoothing effect to this field data. To apply a moisture smoothing effect to the field, replace the moisture level of each soil cell (i, j) with the average value of its original moisture level moistureGrid[i][j] and the mean moisture level of its neighboring cells (defined as neighbors (i, j)). Soil cell (k, 1) is included in neighbors (i, j) if it satisfies the conditions abs (i-k)< smoothingRadius and abs (j -1) smoothingRadius The mean moisture level is defined as mean (values) = sum(values) // values.length where // is an integer division operator. The integer division operator // is equivalent to taking an integer part of a real division. So, the formula for replacing the moisture level of each soil cell is: updated_moisture[i][j] = (moisture[i][j]+ mean (neighbors (i, j))) // 2 Please note that some of the 8 possible neighbors might be missing, and the mean function should only take existing neighbors into account. If a soil cell doesn't have any neighbors, its moisture level should not change after smoothing.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than o(moistureGrid. length * moistureGrid[0].length) will fit within the execution time limit. The fourth question is more difficult. You need to change the formula first: x[i]-y[j] = x[j]-y[i] x[i]+y[i] = x[j]+y[j] s[k] = x[k]+y[k] Count each type and the frequency of occurrence (c), Adding up all c(c-1)/2 is the answer You are a chemist working in a laboratory that studies molecular compounds. You have two arrays representing the atomic weights of elements in two different compounds: x represents the primary elements and y represents the secondary elements. Your research has shown that when two compounds have the same "balance factor" (calculated as the difference between primary and secondary atomic weights), they can potentially form stable molecular bonds. Your task is to analyze these compound arrays and determine how many unique molecular pairings could potentially form stable bonds. A stable bond occurs when the balance factor of one compound position matches the balance factor of another position. Count the total number of valid molecular pairings (i, j) and the balance factors are equal: x[i]-y[j] = x[j] - y[i].
About This Question
This is a reported interview question from a meta interview for a swe role during the oa round reported in 2025.
It covers the following topics: Arrays, Matrix .
Difficulty rating: Hard