Category: math
Given a matrix with dimension NxN, rotate the matrix in place the 90 degrees clockwise and anti-clockwise. For example, original Matrix 3×3: vector<vector<int>> matrix({ {1, 2, 3}, {4, 5, …
A Math Problem: Family’s Age This year, sum of the family ‘s age is 100. There are Dad, Mum, Brother, and Sister in the family. And we know: Brother …
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. Example: MovingAverage m = new MovingAverage(3); m.next(1) = 1 …
Consider the following function to make changes to an array of numbers: func modify(arr, op, idx) { // add by 1 index idx if (op == 0) { arr …
Given a equation , let’s find the real value of x. First, divide both sides by which becomes: as , and , it becomes: Let’s replace with and further …