LeetCode #2485

Find the Pivot Integer

1개의 풀이 · C++

문제 원문 보기 ↗

SOLUTION INFO

C++ · main.cpp

main.cpp
class Solution {
public:
    int pivotInteger(int n) {
        int x = n * (n + 1) / 2;
        int sq = sqrt(x);
        return sq * sq == x ? sq : -1;
    }
};

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.