BudiBadu Logo
00:00

Gallery Stock Order Check

Sorting Algorithms Easy 0 views

The curators catalogue every frame that arrives for the weekend gallery pop-up, recording the widths as integers in the exact order the courier stacked them. Before any labels print, the team wants reassurance that the stack already moves from the narrowest frame to the widest, avoiding a late reshuffle that could scratch delicate pieces. Your routine will accept the recorded sequence and report whether the list is already in nondecreasing order without altering a single entry. Think of it as the calm yes-or-no signal that tells the floor crew whether they can roll the rack straight onto the showroom floor.

The measurements might repeat when twin frames support a matched diptych, and the manifest can even be empty because a shipment was delayed; both situations should still return a decisive answer. The routine must leave the input untouched, simply scanning it from front to back and returning true only if every frame is less than or equal to the next. One misplaced width means the crew needs to pause and reorder before mounting placards, so the routine should return false in that case. Provide the verdict that keeps the artisans confident during setup.

Example 1:

Input: widths = [12,18,18,21]
Output: true
Explanation: The widths never decrease, so the rack can move directly to the gallery floor.

Example 2:

Input: widths = [24,19,20]
Output: false
Explanation: The second entry breaks the nondecreasing order, signalling a rearrangement is needed.

Example 3:

Input: widths = []
Output: true
Explanation: An empty manifest is trivially ordered, so the crew can proceed when the shipment arrives.

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.

BudiBadu Logo

Gallery Stock Order Check

Sorting Algorithms Easy 0 views

The curators catalogue every frame that arrives for the weekend gallery pop-up, recording the widths as integers in the exact order the courier stacked them. Before any labels print, the team wants reassurance that the stack already moves from the narrowest frame to the widest, avoiding a late reshuffle that could scratch delicate pieces. Your routine will accept the recorded sequence and report whether the list is already in nondecreasing order without altering a single entry. Think of it as the calm yes-or-no signal that tells the floor crew whether they can roll the rack straight onto the showroom floor.

The measurements might repeat when twin frames support a matched diptych, and the manifest can even be empty because a shipment was delayed; both situations should still return a decisive answer. The routine must leave the input untouched, simply scanning it from front to back and returning true only if every frame is less than or equal to the next. One misplaced width means the crew needs to pause and reorder before mounting placards, so the routine should return false in that case. Provide the verdict that keeps the artisans confident during setup.

Example 1:

Input: widths = [12,18,18,21]
Output: true
Explanation: The widths never decrease, so the rack can move directly to the gallery floor.

Example 2:

Input: widths = [24,19,20]
Output: false
Explanation: The second entry breaks the nondecreasing order, signalling a rearrangement is needed.

Example 3:

Input: widths = []
Output: true
Explanation: An empty manifest is trivially ordered, so the crew can proceed when the shipment arrives.

00:00
Loading editor...
Test Results

Run your code to see test results

Click the Submit button to execute your solution

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.