From 15a0f9f4f9c9179ca8c6f505389a74a2f29c2107 Mon Sep 17 00:00:00 2001 From: MAHESH ADDAGATLA <158994925+Mahesh-addagatla@users.noreply.github.com> Date: Tue, 30 Jul 2024 20:35:20 +0530 Subject: [PATCH] Create 1653. Minimum Deletions to Make String Balanced.java --- .... Minimum Deletions to Make String Balanced.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 1653. Minimum Deletions to Make String Balanced.java diff --git a/1653. Minimum Deletions to Make String Balanced.java b/1653. Minimum Deletions to Make String Balanced.java new file mode 100644 index 0000000..4a86a21 --- /dev/null +++ b/1653. Minimum Deletions to Make String Balanced.java @@ -0,0 +1,13 @@ +class Solution { + public int minimumDeletions(String s) { + int c=0,ans=0; + for(char ch:s.toCharArray()){ + if(ch=='b')c++; + else if(c!=0){ + ans++; + c--; + } + } + return ans; + } +}