Artisan Label String
The technical objective is to consolidate an array of fragrance label strings into a single, formatted string where each label appears on an individual line, ordered alphabetically. This transformation allows creative teams to generate structured rosters for proofing, inventory logging, and promotional use with zero manual reformatting.
The final output must be a single string consisting of all input labels, including duplicates, sorted character-by-character in ascending order and joined by newline characters (\n). The solution must handle single-entry lists, mixed-case strings, and empty input arrays, returning an empty string in the latter case. This ensures a consistent, paste-ready format that integrates seamlessly with boutique workshop production workflows.
Example 1:
Input: labels = ["Silver Lace", "Aurora Bloom", "Aurora Bloom", "Cedar Mist"]
Output: "Aurora Bloom\nAurora Bloom\nCedar Mist\nSilver Lace"
Example 2:
Input: labels = ["Indigo Fern"]
Output: "Indigo Fern"
Example 3:
Input: labels = ["amber", "Citrus Rise", "Bluff"]
Output: "Bluff\nCitrus Rise\namber"
Algorithm Flow

Best Answers
import java.util.*;
class Solution {
public String compose_artisan_labels(String[] labels) {
if (labels.length == 0) return "";
String[] sortedArr = labels.clone();
Arrays.sort(sortedArr);
return String.join("\n", sortedArr);
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
