Minimum Number of Changes to Make Binary String Beautiful

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
You are given a 0-indexed binary string s having an even length.
A string is beautiful if it's possible to partition it into one or more substrings such that:
Each substring has an even length.
Each substring contains only
1's or only0's.
You can change any character in s to 0 or 1.
Return the minimum number of changes required to make the string s beautiful.
LeetCode Problem - 2914
class Solution {
public int minChanges(String s) {
// Get the length of the string
int length = s.length();
// Initialize a counter to track the number of changes needed
int count = 0;
// Loop through the string, considering pairs of adjacent characters
// Increment i by 2 to examine pairs (i, i+1)
for (int i = 0; i < length - 1; i += 2) {
// Extract the two adjacent characters (temp0 and temp1)
char temp0 = s.charAt(i);
char temp1 = s.charAt(i + 1);
// If the two characters are different, increment the count
if (temp0 != temp1) {
count++;
}
}
// Return the total count of changes needed
return count;
}
}




