Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 2640

Please help with this DSA Problem will share the prize

by cyphur23719 - 14 May, 2022 - 07:51 PM
This post is by a banned member (cyphur23719) - Unhide
213
Posts
5
Threads
3 Years of service
#1
Your are given an array A with size N. A pair of P and Q will be considered "accepted" if the following conditions are valid:
  • P and Q are non-empty sub-sequences of array A of equal length
  • Summation of (Pi + Qi) = X
  • Summation of (Pi - Qi) = Y
  • Summation is taken over all elements of P and Q
Find the number of such accepted pairs.

 Example
 
Assumptions
  • T = 1
  • N = 3
  • X = 4
  • Y = 2
  • A = [3, 1, 1]
Approach
 
There are two accepted pairs:
  • P=[3] for 3 at indexand Q=[1] for 1 at index 2, (3+1) will be 4(equals to X) and (3-1) will be 2(equals to Y)
  • P=[3] for 3 at indexand Q=[1] for 1 at index 3, (3+1) will be 4(equals to X) and (3-1) will be 2(equals to Y)
Therefore, there are only two accepted pairs, so the output is 2.
This post is by a banned member (JC_VD) - Unhide
This post is by a banned member (cyphur23719) - Unhide
213
Posts
5
Threads
3 Years of service
#3
(14 May, 2022 - 07:53 PM)JC_VD Wrote: Show More
42

????
This post is by a banned member (Steadfast2201) - Unhide
53
Posts
3
Threads
2 Years of service
#4
Yes sir i am competitive programmer.
Can you discord me @Ramzes.
Or telegram at @Steadfast2201.
This post is by a banned member (cyphur23719) - Unhide
213
Posts
5
Threads
3 Years of service
#5
(04 October, 2022 - 06:22 AM)Steadfast2201 Wrote: Show More
Yes sir i am competitive programmer.
Can you discord me @Ramzes.
Or telegram at @Steadfast2201.

Could you send your discord @ I can't seem to find you by that username.
This post is by a banned member (Steadfast2201) - Unhide
53
Posts
3
Threads
2 Years of service
#6
steadfast#6790

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)