LeetCode 709. To Lower Case (LaTeX)

Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.

Example

Example 1:

Input: "Hello"
Output: "hello"

Example 2:

Input: "here"
Output: "here"

Example 2:

Input: "LOVELY"
Output: "lovely"

Solution

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{datetime2}
\usepackage{expl3}

\begin{document}
\setlength{\parindent}{0cm}

\ExplSyntaxOn


\cs_set:Npn \to_lower_case #1 {
    \tl_set:Nx \l_tmpa_tl {\tl_lower_case:n {#1}}
    \tl_use:N \l_tmpa_tl
}

\par\to_lower_case{Hello}
\par\to_lower_case{here}
\par\to_lower_case{LOVELY}

\ExplSyntaxOff

\DTMnow

\end{document}

Output

hello
here
lovely
2020-06-10 17:44:18-04:00