CPE OJ - B001 - Pair Sum Count
來源代碼:cpeoj
時間限制:1 s
題目說明
Given an integer array $nums$ of length $n$ and a target value $k$, count the number of index pairs $(i, j)$ such that $ i< j $ and $nums[i]+ nums[j] == k$ .
輸入說明
First line: two integers $n$ and $k$ Second line: $n$ integers $nums[0..n-1]$
$$2≤n≤2×10^5$$ $$−10^9≤nums[i],k≤10^9$$
輸出說明
A single integer: the number of valid pairs. Ends with a newline
輸入輸出範例
範例輸入
5 6 1 5 3 3 2
範例輸出
2
討論
登入後即可加入討論。
登入
目前還沒有討論文章。