1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 01:49:41 +01:00
LeetCode/cpp/largest-odd-number-in-string.cpp
Matej Focko b229608723
cpp(chore): add clang-format style and format
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-01-03 12:06:54 +01:00

13 lines
267 B
C++

#include <string>
class Solution {
public:
std::string largestOddNumber(const std::string &num) {
auto i = num.find_last_of("13579");
if (i == std::string::npos) {
return "";
}
return num.substr(0, i + 1);
}
};