-
Notifications
You must be signed in to change notification settings - Fork 130
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Largest Odd number in a string #216
Comments
Hi @ultimatecoder2, #include <iostream>
#include <string>
using namespace std;
string largestOddNumber(string num){
for(int i = num.size()-1;i>=0; i--){
if((num[i] - '0')%2 == 0)
num.erase(num.begin() + i);
else break;
}
return num;
}
int main()
{
string number="";
cin >> number;
cout << largestOddNumber(number)<<endl;
return 0;
} |
I don't know how to reply to a PR. Waiting for some positive reply |
I just saw few comments on other issues and seems like this is not the proper way to contribute. I mean not to directly giving the possible solution. I apologize for the above inconvenience if it happens. |
Good @nishantkantojha . Your solution seems to be fine. I am assigning this issue to you, so that you can take your time to initiate a pull request. To contribute to this repository, you can try following this video: For any queries, feel free to ask. We would love to see your first pull request. It will also help you to learn more about Git and Github. |
hey...can i work on this issue? |
You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string "" if no odd integer exists.
A substring is a contiguous sequence of characters within a string.
Sample Test Case 1:
Input: num = "52"
Output: "5"
Explanation: The only non-empty substrings are "5", "2", and "52". "5" is the only odd number.
Sample Test Case 2:
Input: num = "4206"
Output: ""
Explanation: There are no odd numbers in "4206".
The text was updated successfully, but these errors were encountered: