FastPrepCalculate y/x using Patch
Problems/Calculate y/x using Patch

Calculate y/x using Patch

Two Sigma logoTwo Sigma● EasyINTERNOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The judged core task matches the reported source at about 95%. Halfway values use round half up so every language returns the same two-decimal string.

Given two integers y and x, compute y / x. The divisor x is nonzero.

Round the quotient to the nearest hundredth using round half up. An exact halfway value is rounded away from zero. Return the result as a string with exactly two digits after the decimal point. If the rounded magnitude is zero, return 0.00 without a negative sign.

Function

calculateRatio(y: int, x: int) → String

Examples

Example 1

y = 10x = 2return = "5.00"

10 / 2 = 5, so the returned two-decimal string is 5.00.

Constraints

  • x != 0
  • Round to the nearest hundredth using round half up.
  • Return exactly two digits after the decimal point.

More Two Sigma problems

  • IPO Share AllocationOA · Seen Sep 2026
  • Sewer Drainage PartitionOA · Seen Sep 2026
  • Daily Temperature By TownOA · Seen Sep 2026
All Two Sigma interview questionsSee Two Sigma hiring insights
Saved
class Solution {
    public String calculateRatio(int y, int x) {
      // write your code here
    }

}
Checking account…