Find Words Containing Character

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 of strings words and a character x.
Return an array of indices representing the words that contain the character x.
Note that the returned array may be in any order.
LeetCode Problem - 2942
import java.util.ArrayList;
class Solution {
// Method to find indices of words containing a specific character
public ArrayList<Integer> findWordsContaining(String[] words, char x) {
// Initialize an ArrayList to store indices of words containing the character
ArrayList<Integer> indices = new ArrayList<>();
// Iterate through the array of words
for (int i = 0; i < words.length; i++) {
// Check if the current word contains the specified character
boolean charFlag = checkChar(words[i], x);
// If the character is found in the word, add its index to the ArrayList
if (charFlag) {
indices.add(i);
}
}
// Return the ArrayList containing indices of words containing the character
return indices;
}
// Method to check if a word contains a specific character
public static boolean checkChar(String str, char z) {
// Convert the word to a character array
char[] strArray = str.toCharArray();
// Iterate through the characters of the word
for (char temp : strArray) {
// If the specified character is found, return true
if (temp == z) {
return true;
}
}
// If the character is not found, return false
return false;
}
}




