← SAP Interview Insights

SAP·Software Engineer·Online Assessment (OA)·Junior

Junior
May 2026

Summary

SAP coding screen, pretty barebones. Just one function to write and that was basically it.

Questions Asked (1)

Q1

Write a function that takes two strings and returns them concatenated together.

Algorithms & Data Structures
Author's notes

Yeah this is exactly as simple as it sounds.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: confirm whether the function should handle null inputs, empty strings, or other edge cases. Then present a simple solution, such as using the language's built-in string concatenation operator, and discuss its time and space complexity. Finally, mention potential optimizations or alternative approaches, like using StringBuilder in Java for multiple concatenations, but emphasize that for two strings, the simple approach is optimal.

Pro tip: Demonstrate awareness of the underlying implementation: in many languages, string concatenation creates a new string, which is O(n+m) time and space. Mentioning this shows you understand performance implications beyond just writing the code.

1. Clarify requirements

Ask about input constraints: can strings be null? Are they mutable? What encoding? This shows attention to detail and avoids assumptions.

2. Propose a simple solution

Write or describe a function that uses the language's concatenation operator (e.g., + in Java, + or += in Python) to join the two strings.

3. Analyze complexity

Explain that the time and space complexity is O(n + m), where n and m are the lengths of the input strings, because a new string of combined length is created.

4. Discuss edge cases

Mention handling of null inputs (e.g., throw IllegalArgumentException or return the non-null string) and empty strings, and how the solution behaves.

5. Consider alternatives and trade-offs

For two strings, the simple approach is best. For multiple concatenations, suggest using a StringBuilder (Java) or join (Python) to avoid O(n^2) performance.

Key Points to Mention

  • Time and space complexity: O(n + m) for concatenation.
  • Null safety: decide on behavior for null inputs (e.g., throw exception or treat as empty).
  • Immutability: strings are immutable in many languages, so concatenation creates a new string.
  • Language-specific idioms: e.g., + operator, concat() method, or StringBuilder for efficiency.
  • Edge cases: empty strings, very large strings, and potential memory implications.
  • Testing: suggest writing unit tests to verify correctness for normal and edge cases.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.