Plus Minus - HackerRank - Java

1 day ago
2

Learn how to solve the HackerRank problem whose title is Plus Minus, using the Java programming language.

The Data Structures and Algorithms (DSA) lesson uses a running sum and loop to solving the question using Java.

Traversing the array, you can keep track of the count of positive and negative integers. The zero count can be calculated later by subtracting positive and negative count from the total number of elements in the array.

After getting the counts, you can calculate the ratio of each kind of count out of the total number of elements in the array.

The function doesn't return anything, but you have to print out the ratios in a specific order, in the specified format.

The time complexity for the solution is O(n) and its space complexity is O(1).

DSA problems are sometimes asked during tech job interviews for positions such as Software Engineer, so you can use the challenge to practice that skill.

Loading 1 comment...