← 返回 citadel 的题目列表Medium Level Algorithm Question
类型:online_judge
Given an integer array nums, your task is to count the number of distinct triplets (i, j, k) such that i < j < k and nums[i] + nums[j] + nums[k] == 0. Present the algorithm complexity and provide the implementation code.
Example:
Input: nums = [-1, 0, 1, 2, -1, -4] Output: 2 Explanation: There are two triplets in the array that meet the requirements: (-1, 0, 1) and (-1, -1, 2).
Example
Input
[-1, 0, 1, 2, -1, -4]