Given a file name fileName, return its extension: the part of the name after the last dot.
Split the name at every dot, and the extension is the last of the parts. A name can have more than one dot, like "archive.tar.gz": only what comes after the last dot is the extension. Keep its letters exactly as they are.
Example 1:
Input: fileName = "photo.jpeg" Output: "jpeg" Explanation: The name has one dot, and "jpeg" comes after it.
Example 2:
Input: fileName = "archive.tar.gz" Output: "gz" Explanation: Splitting at the dots gives "archive", "tar" and "gz". The last part, "gz", is the extension.
Example 3:
Input: fileName = "README.MD" Output: "MD" Explanation: The extension keeps its upper-case letters.
Constraints:
fileNamehas at least one dot, and doesn't start or end with a dot.fileNamehas no spaces: only English letters, digits, dots,-and_.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
