Question DSA-STR-0077
HardA string is built with s = s + c in a loop of n steps in Java. What is the total time?
- A.
O(n log n)
- B.
O(n)
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Strings question
A string is built with s = s + c in a loop of n steps in Java. What is the total time?
O(n log n)
O(n)
Sign up free to see the answer and a step-by-step explanation.
O(n²), since each step copies the whole string
O(1)