FastPrepFlowerbed Capacity Queries
Problems/Flowerbed Capacity Queries

Flowerbed Capacity Queries

LinkedIn logoLinkedIn● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a LinkedIn phone screen. The report describes a version of Can Place Flowers with many queries, each answered in O(1) time. It stresses the case where every plot is empty. It does not say how queries are written, whether the flowerbed changes, or the limits. Here, each query is checked on its own against one flowerbed that never changes. Our version is about 85% the same as the reported question.

You are given a binary array flowerbed, where 1 means a plot already contains a flower and 0 means it is empty. The initial flowerbed is valid: no two occupied plots are adjacent.

You are also given an integer array queries. For each queries[i], determine whether at least that many additional flowers can be planted without placing flowers in adjacent plots.

Every query is independent. Evaluate each query against the same unchanged initial flowerbed; flowers considered for one query do not remain planted for another query.

Return a boolean array answer where answer[i] is true exactly when queries[i] additional flowers can be planted. Preprocess the flowerbed once so that each query is answered in O(1) time.

Function

flowerbedCapacityQueries(flowerbed: int[], queries: int[]) → boolean[]

Examples

Example 1

flowerbed = [1,0,0,0,1]queries = [0,1,2]return = [true,true,false]

The flowerbed has capacity for exactly 1 additional flower, at index 2. Therefore requests for 0 and 1 flowers succeed, while the request for 2 flowers fails.

Example 2

flowerbed = [0,0,0,0,0]queries = [1,3,4]return = [true,true,false]

Flowers can be placed at indices 0, 2, and 4, so the maximum additional capacity is 3.

Example 3

flowerbed = [0]queries = [0,1,2]return = [true,true,false]

The only plot can hold one flower. The independent queries compare 0, 1, and 2 with that capacity.

Constraints

  • 1 <= flowerbed.length <= 2 * 10^4
  • flowerbed[i] is either 0 or 1.
  • The initial flowerbed contains no adjacent occupied plots.
  • 1 <= queries.length <= 2 * 10^4
  • 0 <= queries[i] <= flowerbed.length
  • Queries are independent and do not mutate flowerbed.

More LinkedIn Phone Screen questions

  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
  • Sqrt(x)PHONE SCREEN · Seen Nov 2026
  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
  • Known Words Matching Phone DigitsPHONE SCREEN · Seen Oct 2026
  • Inverse-Depth Nested List SumPHONE SCREEN · Seen Oct 2026
  • Valid Number with ExponentsPHONE SCREEN · Seen Oct 2026
  • Sort a Quadratic-Transformed ArrayPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Fair Capped Money DistributionGusto · PHONE SCREEN · ONSITE INTERVIEWGusto interview questions
  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Jump GamePaytm · PHONE SCREENPaytm interview questions
  • Remove the Fewest Magic BeansThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Gas Station CircuitAngel One · PHONE SCREEN
  • Aggressive CowsAmazon · PHONE SCREEN
  • Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
  • Defer Expenses to Preserve BalanceDRW · PHONE SCREENDRW interview questions
  • Container With Most WaterEPAM · PHONE SCREENEPAM interview questions

LinkedIn interview experiences

  • LinkedIn Senior MLE Interview Questions: 1 Experience
  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public boolean[] flowerbedCapacityQueries(int[] flowerbed, int[] queries) {
        // write your code here
    }
}
Checking account…