Even Numbers as String
You’re compiling a weekly report for a customer service team. You receive a list of integers, but only the Even Numbers correspond to actual processed transactions. Your mission in Even Numbers as String is to pull out these even values in order and format them as a single comma-separated string.
The "secret sauce" is Filtering and Joining. As you scan the numbers, you collect only values where number % 2 == 0. This includes negative even numbers (refunds) and zeroes. Once you have the collection, you join them with a comma. This ensures the accounting team can read the transaction log quickly. If no even numbers are found, return an empty string. This challenge is a great way to practice basic array filtering and string formatting to turn raw data into a clean, human-readable report for efficient auditing!
For text and token tasks, be precise with index movement and substring boundaries. Most hidden failures come from partial-match handling and boundary cuts, so keep comparisons explicit and avoid assumptions about implicit separators or formatting not guaranteed by the input contract.
Examples
Collect the even values while keeping their order.
No even numbers exist, so return an empty string.
Only 2 and 4 are even, so the string becomes "2,4".
Algorithm Flow

Best Answers
import java.util.stream.*;class Solution{public String even_to_string(Object n){int[]a=(int[])n;return IntStream.of(a).filter(x->x%2==0).mapToObj(String::valueOf).collect(Collectors.joining(","));}}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
