Explanation

523.Find the Quotient and Remainder

Easy
Given a non-negative dividend and a positive divisor, return [quotient, remainder]: how many whole times the divisor fits into the dividend, and what is left over. Division with a remainder is the long division you learnt at school, and it underlies many later problems (digit extraction, even/odd checks, clock arithmetic). The quotientQuotientThe number of whole times the divisor fits into the dividend. and remainderRemainderWhat is left of the dividend after taking away every whole group of the divisor. always satisfy dividend = quotient × divisor + remainder. The first solution literally removes groups one at a time; the second lets the / and % operators do it instantly.

Example 1:

Input: dividend = 17, divisor = 5

Output: [3,2]

Example 2:

Input: dividend = 4, divisor = 9

Output: [0,4]

+ 5 hidden test cases run on Submit.

Constraints:

  • ●0 ≤ dividend ≤ 1000000
  • ●1 ≤ divisor ≤ 1000000

dividend =

17

divisor =

5