BudiBadu Logo

Market Slate Phrase

Sorting Easy 2 views
Like22

The night market’s storytelling corner needs a new board for its narrators. You receive a list of placard titles exactly as the performers handed them over. Your task in Market Slate Phrase is to return a single polished string where entries are sorted alphabetically and separated by " | ". This allows the signage crew to update the board without late-night edits!

The "secret sauce" is Sorting and Joining. Your routine must keep every card title exactly as written—casing and emoji included—arranging them from A to Z before joining them with the bar separator. This approach leaves the original archival list untouched while presenting a ready-to-print summary for the crew. If no titles have been submitted, return an empty string to indicate a blank slate. This practical task turns a jumble of entries into a clean, professional display for public-facing systems!

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

Example 1
Input
titles = ["Moonlit Trail","Amber Echo","Amber Echo","Garden Lanterns"]
Output
Amber Echo | Amber Echo | Garden Lanterns | Moonlit Trail
Explanation

Each card title remains intact while the phrase alphabetizes the lineup with bar separators.

Example 2
Input
titles = ["ember","Aurora Pulse","Beacon"]
Output
Solace
Explanation

Titles keep their original casing while the phrase follows alphabetical comparison.

Example 3
Input
titles = ["Solace"]
Output
Aurora Pulse | Beacon | ember
Explanation

A single card returns exactly as received because it already meets the ordering rule.

Algorithm Flow

Recommendation Algorithm Flow for Market Slate Phrase - Budibadu
Recommendation Algorithm Flow for Market Slate Phrase - Budibadu

Best Answers

java
import java.util.*;

class Solution {
    public String market_slate_phrase(String[] titles) {
        if (titles.length == 0) return "";
        String[] sorted = titles.clone();
        Arrays.sort(sorted);
        return String.join(" | ", sorted);
    }
}