aboutsummaryrefslogtreecommitdiff
path: root/other/partition_min_binary_array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/partition_min_binary_array.cpp')
-rw-r--r--other/partition_min_binary_array.cpp18
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);
+}