diff options
Diffstat (limited to 'other/partition_min_binary_array.cpp')
-rw-r--r-- | other/partition_min_binary_array.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/other/partition_min_binary_array.cpp b/other/partition_min_binary_array.cpp new file mode 100644 index 0000000..8cec267 --- /dev/null +++ b/other/partition_min_binary_array.cpp @@ -0,0 +1,18 @@ +#include "leetcode.h" + +class Solution { +public: + int minPartitions(string n) { + char ans = '0'; + for (char c : n) + if (c > ans) + ans = c; + return ans - '0'; + } +}; + +int main() { + Solution obj; + string n = "32"; + cout << obj.minPartitions(n); +} |