Find Maximum Number of String Pairs

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 array words consisting of distinct strings.
The string words[i] can be paired with the string words[j] if:
The string
words[i]is equal to the reversed string ofwords[j].0 <= i < j < words.length.
Return the maximum number of pairs that can be formed from the array words.
Note that each string can belong in at most one pair.
LeetCode Problem - 2744
class Solution {
public int maximumNumberOfStringPairs(String[] words) {
int count = 0; // Initialize count to keep track of the pairs
for(int i=0; i<words.length; i++){ // Iterate through each word in the array
for(int j=i+1; j<words.length; j++){ // Iterate through the remaining words in the array
// Check if the first character of word[i] is equal to the second character of word[j] and vice versa
if (words[i].charAt(0) == words[j].charAt(1) && words[i].charAt(1) == words[j].charAt(0)){
count++; // Increment count if the condition is met
break; // Break out of the inner loop since a pair is found
}
}
}
return count; // Return the count of pairs
}
}




