Festival Cabins Sorted Flag
During the festival, lodging requests are logged exactly as guests arrive. Coordinators list the cabin names with various casing and spacing. Before the evening rush, the team needs a quick signal to know if the queue is already alphabetical so they can release the ushers. Your task in Festival Cabins Sorted Flag is to return true if the list is sorted case-insensitively, or false otherwise.
The "secret sauce" here is a Linear Comparison Scan. You walk through the list and compare each name to the one before it, making sure to convert them to the same case first. Comparisons should ignore casing, meaning "Star" and "star" are equal. Extra spaces inside names are intentional and should be left alone. If the list is empty, return true. This check provides a reliable flag that keeps the festival walkway clear of last-minute scrambles. It’s a simple, non-destructive way to validate incoming data!
If sorting is part of the strategy, do it intentionally as a preprocessing step to simplify downstream logic such as merging, ordering, or comparison. After sorting, keep output semantics precise: preserve expected structure, avoid dropping valid entries, and ensure tied cases still follow deterministic order rules.
Examples
"Harbor Light" should appear after "Garden Nook" when compared alphabetically.
An empty arrival log is already in order, so the ushers can stand down.
Each name follows the next alphabetically when casing is ignored.
Algorithm Flow

Best Answers
class Solution {
public boolean is_festival_sorted(int[] nums) {
for (int i = 0; i < nums.length - 1; i++) {
if (nums[i] > nums[i+1]) return false;
}
return true;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
