编写一个函数
int solution(int A[], int N);
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
int solution(vector<int> &A);
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
int solution(vector<int> &A);
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
class Solution { public int solution(int[] A); }
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
int solution(List<int> A);
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
func Solution(A []int) int
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
class Solution { public int solution(int[] A); }
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
class Solution { public int solution(int[] A); }
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
function solution(A);
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
fun solution(A: IntArray): Int
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
function solution(A)
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
int solution(NSMutableArray *A);
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
function solution(A: array of longint; N: longint): longint;
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
function solution($A);
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
sub solution { my (@A) = @_; ... }
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
def solution(A)
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
def solution(a)
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
object Solution { def solution(a: Array[Int]): Int }
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
public func solution(_ A : inout [Int]) -> Int
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
function solution(A: number[]): number;
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
编写一个函数
Private Function solution(A As Integer()) As Integer
给出一个以0为起始索引的数组 A,其中包含 N 个整数, 返回 A 中不重复的整数的个数:
|{ A[i] : 0 ≤ i < N}|.
例如,给出
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1你的函数应该返回 3,因为数组 A 中包括数字 {1,2,3}.
假定:
- N 是 [0..100,000] 内的 整数;
- 数组 A 每个元素是取值范围 [−1,000,000..1,000,000] 内的 整数 .
Write a function
int solution(int A[], int N);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
int solution(vector<int> &A);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
int solution(vector<int> &A);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
class Solution { public int solution(int[] A); }
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
int solution(List<int> A);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
func Solution(A []int) int
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
class Solution { public int solution(int[] A); }
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
class Solution { public int solution(int[] A); }
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
function solution(A);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
fun solution(A: IntArray): Int
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
function solution(A)
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Note: All arrays in this task are zero-indexed, unlike the common Lua convention. You can use #A to get the length of the array A.
Write a function
int solution(NSMutableArray *A);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
function solution(A: array of longint; N: longint): longint;
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
function solution($A);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
sub solution { my (@A) = @_; ... }
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
def solution(A)
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
def solution(a)
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
object Solution { def solution(a: Array[Int]): Int }
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
public func solution(_ A : inout [Int]) -> Int
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
function solution(A: number[]): number;
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].
Write a function
Private Function solution(A As Integer()) As Integer
that, given an array A consisting of N integers, returns the number of distinct values in array A.
For example, given array A consisting of six elements such that:
A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer within the range [−1,000,000..1,000,000].