[
math
]
BinarySearch 0367 Sum of First N Odd Integers
Problem statement
https://binarysearch.com/problems/Sum-of-First-N-Odd-Integers/
Solution
Just use math to get answer of arithmetic sequence, which is n*n
.
Complexity
It is O(1)
for time and space.
Code
class Solution:
def solve(self, n):
return n*n