LearnFrenzy
Sign in Take a free test

Strings · Exercise 4 of 4

Strings String Programs

  • 8 questions
  • Page 1 of 1
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Interview-style string problems. Write each one yourself first, then open the solution – every solution was compiled and run, and the output shown is the real output. Tick "Mark as solved" to track your progress.

Question 1 Easy

Reverse a string in place without a second buffer. It must also work for an empty string.

Question page & discussion
Question 2 Medium

Check whether a sentence is a palindrome, ignoring case, spaces and punctuation.

Question page & discussion
Question 3 Medium

Check whether two strings contain exactly the same characters, in O(n) time.

Question page & discussion
Question 4 Easy

Count the words in a string where words may be separated by several spaces or tabs, with spaces at both ends.

Question page & discussion
Question 5 Hard

Turn "pointers are fun" into "fun are pointers" in place, without a second buffer.

Question page & discussion
Question 6 Medium

Find the first character that appears exactly once, or report that there is none.

Question page & discussion
Question 7 Hard

Write parse_int() that accepts only a complete, in-range integer and rejects empty text, trailing junk and overflow.

Question page & discussion
Question 8 Medium

Compress a string by run-length encoding: "aaabbcddddd" becomes "a3b2c1d5". Never overflow the output buffer.

Question page & discussion
All exercises doneBack to StringsRevise the concepts or pick another topic

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Popular