2 051
Subscribers
No data24 hours
No data7 days
No data30 days
Posts Archive
Hi VARUN , Welcome to this Community for 2022 Batch Daily Off Campus Jobs Updates join this channel β
ππ
@offcampusjobs_0
@offcampusjobs_0
02 Apr 2021, 01:35
Hi 0798 Join Our Channel for daily Off-Campus Job Updates β€οΈ
ππ
@offcampusjobs_0
@offcampusjobs_0
12 Jan 2022, 04:54
Hi harry , Welcome to this Community for 2022 Batch Daily Off Campus Jobs Updates join this channel β
ππ
@offcampusjobs_0
@offcampusjobs_0
02 Apr 2021, 23:09
Hi Ravi Join Our Channel for daily Off-Campus Job Updates β€οΈ
ππ
@offcampusjobs_0
@offcampusjobs_0
25 Dec 2021, 22:12
Hi Jaydip Join Our Channel for daily Off-Campus Job Updates β€οΈ
ππ
@offcampusjobs_0
@offcampusjobs_0
13 Jan 2022, 12:38
Hi S Join Our Channel for daily Off-Campus Job Updates β€οΈ
ππ
@offcampusjobs_0
@offcampusjobs_0
10 Jan 2022, 07:08
Distinct numbers
You are given an array A consisting of N integers.
X[i] is the number of distinct values that occur to the left of index i and not on or to the right of index 1.
Y[] is the number of distinct values that occur to the right of index i and not on or to the left of index i
Task -
Determine the absolute difference of X[I], Y[I] for every index 1 β€ i β€ N
Example -
Assumptions:
N=5
A=[7,7,3,2,3]
Approach:
β’ The number of distinct elements that occur to the left of index / and not on or to the right of Index //1β€iβ€N) are as follows: X = [0, 0, 1, 1, 2]
β’ The number of distinct elements that occur to the right of index / and not on or to the left of index // 1β€iβ€N) are as follows: Y = [2, 2, 1, 0, 0]
β’ Therefore, the answer to this test case for every index / (1 β€ i β€N) are as follows: ans = (2, 2, 0, 1, 2)
Function description
Complete the function solve provided in the editor. This function takes the following parameter and returns the required answer:
N: Represents the size of the array A
A: Represents the elements of array A
Input format -
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button)
The first line contains T denoting the number of test cases T also specifies the number of times you h to run the solve function on a different set of inputs
β’ The first line contains T denoting the number of test cases. T also specifies the number of times you have to run the solve function on a different set of inputs.
For each test case:
β’ The first line consisting of a single integer N denoting the size of the array A.
β’ The second line consisting of N space-separated integers denoting the elements of the array A
Output format -
For each test case in a new line, print a list of N space-separated integers representing the answer
Constraints:
1 β€ T β€ 10
1 β€ N β€2 * 10^5
-10^9 β€ Ai β€ 10^9
Code snippets (also called starter code/boilerplate code) -
Sample Input 1:
1
4
4 3 2 3
Sample Input 2:
2012
Explanation
The first line contains the number of test cases, T = 1
The first test case
Given
β’ N = 4
β’ A = [4, 3, 2, 3]
Approach
β’ The number of distinct elements that occur to the left of index and not on or to the right of index/(1β€iβ€N) are as follows: X = [0, 1, 1, 2]
β’ The number of distinct elements that occur to the right of index and not on or to the left of index /(1β€iβ€N) are as follows: Y = [2, 1, 0, 0]
Therefore, the answer to this test case for every index (1siN) are as follows: ans = (2, 0, 2)
26 Sep 2021, 11:05
Hi sahithi , Welcome to this Community for 2022 Batch Daily Off Campus Jobs Updates join this channel β
ππ
@offcampusjobs_0
@offcampusjobs_0
03 Apr 2021, 03:13
Hi Prashant , Welcome to this Community for 2022 Batch Daily Off Campus Jobs Updates join this channel β
ππ
@offcampusjobs_0
@offcampusjobs_0
03 Apr 2021, 00:43
