GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 11 May 2022

[Solution] Good Pairs CodeChef Solution | CodeChef Problem Solution 2022

You are given arrays A and B of length N each. Determine the number of good pairs.

A pair (i,j) (1i,jN) is said to be good if all of the following conditions are satisfied:

  • i<j;
  • Ai=Bj;
  • Aj=Bi;

Input Format

  • First line will contain T, the number of test cases. Then the test cases follow.
Solution Click Below:-  CLICK HERE

Description of each test case:

  • First line contains an integer N - denoting the length of the arrays.
  • Second line contains N space-separated integers A1,A2,AN - denoting the array A.
  • Third line contains N space-separated integers B1,B2,BN - denoting the array B.

Output Format

For each test case, output the number of good pairs.

Constraints

  • 1T1000
  • 2N105
  • 1Ai,Bi109
  • Sum of N over all test cases does not exceed 2105.

Join Now for Solution:- 

No comments:

Post a Comment