Many data-processing APIs (including Spark, functional collections, and stream libraries) provide both map() and flatMap(). Confusing them often leads to nested outputs, incorrect counts, or unexpected downstream behavior.
Explain the difference between map() and flatMap().
n, what can you say about the size and structure of the output from map() vs flatMap()?map(split) differs from flatMap(split).Focus on semantics (nesting vs flattening), typical use cases (tokenization, exploding lists), and common mistakes. You may mention performance implications at a high level, but prioritize correctness and reasoning about output structure.