LeetCode Weekly Contest 169 1問目 - Find N Unique Integers Sum up to Zero [1304]

Source

LeetCode Weekly Contest 169
問題文

問題概要

省略

解法

省略

cLayversion 20200214-1)のコード

C++に変換後のコードはこちら

#define main dummy_main
{}
#undef main

class Solution {
public:
  vector<int> sumZero(int n) {
    vector<int> res;
    if(n%2) res.push_back(0);
    rep(i,n/2){
      res.push_back(i+1);
      res.push_back(-(i+1));
    }
    return res;
  }
};

Current time: 2024年04月19日07時01分33秒
Last modified: 2020年02月16日02時07分03秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る

Logged in as: unknown user (not login)

ログイン: