Skills101
← All practice quizzes

Strings Quiz

8 questions10 minPass: 60%+10 XP on first pass

Immutability, StringBuilder, palindromes, reversing words and expand-around-center.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    Why is s = s + ch inside a loop slow in Java and Python?

  2. Question 2

    In Java, how should you compare the contents of two strings a and b?

  3. Question 3

    What does this print?

    s = "  the sky  is blue "
    print(" ".join(reversed(s.split())))
    
  4. Question 4

    What does this print?

    System.out.println('c' - 'a');
    
  5. Question 5

    How many centers does "expand around center" check for a string of length n?

  6. Question 6

    What is the longest palindromic substring of "babad"? (either correct answer is accepted)

  7. Question 7Select all that apply

    Which techniques are commonly used for string problems? (select all that apply)

  8. Question 8

    What is the longest common prefix of ["flower", "flow", "flight"]?