Category: Uncategorized
-
Reliability
Measured by Mean Time Between Failures (MTBF) and Mean Time To Recover (MTTR). MTBF . Note, the numerator excludes downtime which may be contributed by maintenance or repair. In other words, . It measures how often good time had been punctured by failures. We want high MTBF. MTTR . Measures how good the repair mechanism…
-
Availability
Within a time period of units, if a system is down for units, then its availability for the time period is defined as . It usually is expressed as percentage. In other words, . We note that is a linear function of down time with a slope of . Therefore, if down time increases, availability…
-
LeetCode 322: Coin Change
link We can use Dynamic Programming. Sub-problem Say solutions[amount] represents the minimum number of coins required to change that amount. A sub-problem, solutions[amount-coin], may not be solvable and to represent that case we initialize solutions with except solutions[0] which has trivial solution 0. Order Since solutions[amount] depends on the solutions[amount-coin] and coin is positive, if…
-
LeetCode 51: N-Queens
link We place queens one row at a time keeping track of columns, main diagonals, and sub-diagonals under attack. For each row we place the queen on a column if (row, column) is not already under attack — horizontally, vertically, or diagonally. For some row, if we cannot find a non-attacked column, we backtrack. Main…
-
LeetCode 121: Best Time to Buy and Sell Stock
link Profit is (sell-buy). For each possible buy, we find the best sell (max day’s price) in the future. Time: , space: . Going through the days in sequence, we keep track of the best_buy; therefore, the minimum price seen so far. Everyday we consider selling and to compute the max_profit for that day we…
-
LeetCode 670: Maximum Swap
link A swap cannot increase numbers like below: We need an increasing pair. Those two numbers will be candidate for swap. We can improve the right. Given the improved right, now we can also improve the left. Time: , space: .
-
LeetCode 1404: Number of Steps to Reduce a Number in Binary Representation to One
link Time: , space: . Observations Or, more concisely: