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
|
1074 Discussions
|
Please Login in order to post a comment
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:
For C#
return string.Concat(Enumerable.Range(0, s.Length / 3) .Select(s => "SOS")) .Select((c, i) => c != s[i] ? 1 : 0) .Sum();
Here is problem solution in python java c++ c and Javascript - https://programmingoneonone.com/hackerrank-mars-exploration-problem-solution.html
Here is my c++ solution, you can find the explanation here : https://youtu.be/Gf0fpGE83r4