Skip to main content

Command Palette

Search for a command to run...

Count Pairs That Form a Complete Day I

Published
1 min read
Count Pairs That Form a Complete Day I
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.

Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.

A complete day is defined as a time duration that is an exact multiple of 24 hours.

For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so on.

LeetCode Problem - 3184

class Solution {
    public int countCompleteDayPairs(int[] hours) {
        // Initialize the answer to store the count of valid pairs
        int answer = 0;

        // Iterate through each hour in the array
        for(int i = 0; i < hours.length; i++) {
            // For each hour, iterate through the subsequent hours
            for(int j = i + 1; j < hours.length; j++) {
                // Check if the sum of the two hours is a multiple of 24
                if((hours[i] + hours[j]) % 24 == 0) {
                    // If it is, increment the answer count
                    answer++;
                }
            }
        }

        // Return the total count of pairs that sum to a complete day
        return answer;
    }
}

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.