From b97740ce175e56e4abe61cb23e266f1733652cfd Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Fri, 8 Dec 2023 00:51:42 +0530 Subject: [PATCH] Create 1903. Largest Odd Number in String --- 1903. Largest Odd Number in String | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 1903. Largest Odd Number in String diff --git a/1903. Largest Odd Number in String b/1903. Largest Odd Number in String new file mode 100644 index 0000000..a69c51c --- /dev/null +++ b/1903. Largest Odd Number in String @@ -0,0 +1,11 @@ +class Solution { +public: + string largestOddNumber(string num) { + int i=num.size(); + while(i--){ + if(num[i]=='1'||num[i]=='3'||num[i]=='5'||num[i]=='7'||num[i]=='9') + return num.substr(0,i+1); + } + return ""; + } +};