Percentage of Letter in String

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.
Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.
LeetCode Problem - 2278
class Solution {
public int percentageLetter(String s, char letter) {
double countOfletter = 0; // Initialize a counter to keep track of the occurrences of the specified letter
// Iterate over each character in the string 's'
for (char ch : s.toCharArray()) {
// If the current character matches the specified 'letter', increment the counter
if (ch == letter) {
countOfletter++;
}
}
// Calculate the percentage of the specified letter in the string
double len = s.length(); // Get the length of the string
int result = (int) ((countOfletter / len) * 100); // Calculate the percentage and cast it to an integer
return result; // Return the calculated percentage as an integer
}
}




