Statistics

Problem Statement for "TitleString"

Problem Statement

A common word-processing task is capitalizing the first letter of each word in a title. Write a class TitleString with a method toFirstUpperCase that takes a String title containing lowercase words separated by one or more space characters and returns a String that is identical to title except with the first character of each word capitalized.

Definition

Class:
TitleString
Method:
toFirstUpperCase
Parameters:
String
Returns:
String
Method signature:
String toFirstUpperCase(String title)
(be sure your method is public)

Notes

  • title may have leading or trailing spaces.

Constraints

  • title will contain between 0 and 50 characters, inclusive.
  • Each character of title will either be a space or a lowercase letter ('a' to 'z').

Examples

  1. "introduction to algorithms"

    Returns: "Introduction To Algorithms"

  2. "more than one space between words"

    Returns: "More Than One Space Between Words"

  3. " lord of the rings the fellowship of the ring "

    Returns: " Lord Of The Rings The Fellowship Of The Ring "

  4. " "

    Returns: " "

  5. "i"

    Returns: "I"

  6. "the king and i"

    Returns: "The King And I"

  7. ""

    Returns: ""

  8. "px ilfkus nj f ovql lkrjnn b"

    Returns: "Px Ilfkus Nj F Ovql Lkrjnn B"

  9. "y a"

    Returns: "Y A"

  10. "j shz"

    Returns: "J Shz"

  11. "xjj shkyckfvkyy ia pu"

    Returns: "Xjj Shkyckfvkyy Ia Pu"

  12. "kj"

    Returns: "Kj"

  13. "xaon"

    Returns: "Xaon"

  14. "mk lky lk u ybu qp "

    Returns: "Mk Lky Lk U Ybu Qp "

  15. "rl"

    Returns: "Rl"

  16. "ykexwcl y t "

    Returns: "Ykexwcl Y T "

  17. "c "

    Returns: "C "

  18. " hmsupo mrjo w svwzjqk qudaixfue ivemgsq "

    Returns: " Hmsupo Mrjo W Svwzjqk Qudaixfue Ivemgsq "

  19. "daf"

    Returns: "Daf"

  20. "vo gcdfzse"

    Returns: "Vo Gcdfzse"

  21. "rvrhg cr"

    Returns: "Rvrhg Cr"

  22. "gdsdhyizrevv"

    Returns: "Gdsdhyizrevv"

  23. "enapoktgxo lqloeslni "

    Returns: "Enapoktgxo Lqloeslni "

  24. "d "

    Returns: "D "

  25. "v"

    Returns: "V"

  26. "aqf lieekfwa a"

    Returns: "Aqf Lieekfwa A"

  27. "xws t hy qdggr mjwjqdyantvckpm bltlo "

    Returns: "Xws T Hy Qdggr Mjwjqdyantvckpm Bltlo "

  28. "bmis jb yzqtwmqr fvispgb"

    Returns: "Bmis Jb Yzqtwmqr Fvispgb"

  29. "wqoezwaxpl oc go"

    Returns: "Wqoezwaxpl Oc Go"

  30. " j"

    Returns: " J"

  31. " dvp uwyr"

    Returns: " Dvp Uwyr"

  32. " rlsiup wtxu uefvmlq vazh "

    Returns: " Rlsiup Wtxu Uefvmlq Vazh "

  33. "bnx sx"

    Returns: "Bnx Sx"

  34. "t"

    Returns: "T"

  35. "j"

    Returns: "J"

  36. "biqgx"

    Returns: "Biqgx"

  37. "lnmf hf tblckjj qyieklffauj"

    Returns: "Lnmf Hf Tblckjj Qyieklffauj"

  38. "u m iybj y "

    Returns: "U M Iybj Y "

  39. " marjzjff y "

    Returns: " Marjzjff Y "

  40. "xzbks"

    Returns: "Xzbks"

  41. "y mgvo rkscjax osup"

    Returns: "Y Mgvo Rkscjax Osup"

  42. "kss yko"

    Returns: "Kss Yko"

  43. "x tyurv l "

    Returns: "X Tyurv L "

  44. " s sf ksjll e ldah"

    Returns: " S Sf Ksjll E Ldah"

  45. " xkbmi glezojchtaqancpb"

    Returns: " Xkbmi Glezojchtaqancpb"

  46. "ja r wybmrallvp"

    Returns: "Ja R Wybmrallvp"

  47. "cgkxkwhrqgfstmxad nqtk vb mywkd"

    Returns: "Cgkxkwhrqgfstmxad Nqtk Vb Mywkd"

  48. "more than one space between words"

    Returns: "More Than One Space Between Words"

  49. "i"

    Returns: "I"

  50. " lord of the rings the fellowship of the ring "

    Returns: " Lord Of The Rings The Fellowship Of The Ring "

  51. " dupa a nie program"

    Returns: " Dupa A Nie Program"

  52. "more than one space between words"

    Returns: "More Than One Space Between Words"

  53. "i"

    Returns: "I"

  54. " lord of the rings the fellowship of the ring "

    Returns: " Lord Of The Rings The Fellowship Of The Ring "

  55. " dupa a nie program"

    Returns: " Dupa A Nie Program"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: