Skip to main content

Command Palette

Search for a command to run...

Number of Senior Citizens

Published
1 min read
Number of Senior Citizens
G

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 details. Each element of details provides information about a given passenger compressed into a string of length 15. The system is such that:

  • The first ten characters consist of the phone number of passengers.

  • The next character denotes the gender of the person.

  • The following two characters are used to indicate the age of the person.

  • The last two characters determine the seat allotted to that person.

Return the number of passengers who are strictly more than 60 years old*.*

LeetCode Problem - 2678

class Solution {
    // Method to count the number of seniors based on their age
    public int countSeniors(String[] details) {
        // Counter to keep track of seniors
        int ans = 0;
        // Iterating through each detail in the array
        for (String detail : details) {
            // Extracting the age from the detail and converting it to an integer
            int age = Integer.parseInt(detail.substring(11, 13));
            // Checking if the age is greater than 60 (considering seniors)
            if (age > 60) {
                // Incrementing the count if the person is a senior
                ans++;
            }
        }
        // Returning the total count of seniors
        return ans;
    }
}

More from this blog

S

Software and Performance Testing Insights

462 posts

Results-Driven Agile QA Specialist | Expert in Mobile & Web Testing | Proficient in Test Planning, Execution, and Root Cause Analysis.