保存されている過去のバージョンの一覧

2020年12月06日15時13分34秒

LeetCode Weekly Contest 218 2問目 - Max Number of K-Sum Pairs [1679]

Source

LeetCode Weekly Contest 218
問題文

問題概要

省略

解法

省略

cLayversion 20201206-1)のコード

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

#define main dummy_main
{}
#undef main

class Solution {
public:
  int maxOperations(vector<int>& A, int K) {
    int res = 0, N = A.size(), x = 0, y = N-1;
    sort(A.begin(), A.end());
    while(x < y){
      if(A[x] + A[y] == K) res++, x++, y--, continue;
      if[A[x] + A[y] < K, x++, y--];
    }
    return res;
  }
};

Current time: 2024年04月30日14時49分25秒
Last modified: 2020年12月06日15時13分34秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る

Logged in as: unknown user (not login)

ログイン: