CssPropertyConverter
SRM 340 · 2007-02-20 · by Mike Mirzayanov
Problem Statement
CSS property names are typically all lowercase and written in dash-separated notation, which means that each pair of adjacent words is separated by a single dash. For example, "z-index", "padding-left", and "border-collapse" are typical names. However, if you use JavaScript to set CSS style properties, you need to use camel notation, where each word except the first starts with an uppercase letter, and adjacent words are not separated. All other letters are lowercase. For example, "z-index" would become "zIndex" in camel notation.
You are given a String cssPropertyName containing a property name written in dash-separated notation. Convert cssPropertyName to camel notation and return the result.
Constraints
- cssPropertyName will contain between 1 and 50 characters, inclusive.
- cssPropertyName will contain only lowercase letters ('a'-'z') and dashes ('-').
- Each dash in cssPropertyName will be surrounded by two letters.
"z-index" Returns: "zIndex"
"border-collapse" Returns: "borderCollapse"
"top-border-width" Returns: "topBorderWidth"
"a" Returns: "a"
"ba" Returns: "ba"
Submissions are judged against all 74 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CssPropertyConverter with a public method string getCamelized(string cssPropertyName) · 74 test cases · 2 s / 256 MB per case