網頁

2025年3月5日 星期三

Py3 C++算術數列算面積一行解Leetcode 2579 Count Total Number of Colored Cells


Py3 C++算術數列算面積一行解Leetcode 2579  Count Total Number of Colored Cells
利用算術數列面積公式一行解Leetcode 257
[Py3解請進]


-------
Use the formula for arithmetic progression to compute the area  to obtain 1-line solution.

class Solution:
    def coloredCells(self, n: int) -> int:
        return 2*n*(n-1)+1

沒有留言:

張貼留言

HTML 編輯器