Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions clojure/709.clj

This file was deleted.

11 changes: 11 additions & 0 deletions solutions/0701-0800/0709-to-lower-case/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 709. To Lower Case

[LeetCode problem 709](https://leetcode.com/problems/to-lower-case/)

- **Difficulty**: Easy
- **Tags**: string

## Description

Given a string `s`, return the string after converting every uppercase
letter to lowercase.
14 changes: 14 additions & 0 deletions solutions/0701-0800/0709-to-lower-case/solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "solution.hpp"

#include <algorithm>
#include <cctype>

namespace leetcode::p0709 {

std::string solve(std::string s) {
std::ranges::transform(
s, s.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
return s;
}

} // namespace leetcode::p0709
11 changes: 11 additions & 0 deletions solutions/0701-0800/0709-to-lower-case/solution.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <string>

namespace leetcode::p0709 {

// optimized: O(n) time, O(n) space — map each character through
// std::tolower.
std::string solve(std::string s);

} // namespace leetcode::p0709
11 changes: 11 additions & 0 deletions solutions/0701-0800/0709-to-lower-case/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <catch2/catch_test_macros.hpp>

#include "solution.hpp"

TEST_CASE("Problem 709", "[p0709]") {
CHECK(leetcode::p0709::solve("HELLO") == "hello");
CHECK(leetcode::p0709::solve("world") == "world");
CHECK(leetcode::p0709::solve("CloJure") == "clojure");
CHECK(leetcode::p0709::solve("") == "");
CHECK(leetcode::p0709::solve("123!@#") == "123!@#");
}
Loading