We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Strings
- Mars Exploration
- Discussions
Mars Exploration
Mars Exploration
Sort by
recency
|
1077 Discussions
|
Please Login in order to post a comment
int marsExploration(char* s) { char* a = malloc(strlen(s)*sizeof(char)); strcpy(a,s); int count=0; for(int i=0;a[i]!='\0';i++){ if(a[i]!='S' && a[i]!='O') count++; } return count; } Why it is showing only some test cases are fail?
Here is my c++ solution
int marsExploration(string s) { int sz = s.size(); string strSos("SOS");
}
C Solution:
Python solution with O(n/3) time and O(1) time. I am not sure if there is a more efficient solution. If anyone can find something more efficient please comment: