Kevin and His Cards Problem Statement

Kevin has two packs of cards. The first pack contains N cards, and the second contains M cards. Each card has an integer written on it. Determine two results: the total number of distinct card types when considering both packs together, and the number of card types present in both packs.

Note:

Two cards are of different types if their numbers differ.

Example:

Input:
T = 1
N = 3, M = 3
First pack: [2, 3, 5]
Second pack: [3, 4, 5]
Output:
4 2
Explanation:

The distinct card types when both packs are combined are {2, 3, 4, 5}, totaling 4. The common card types between the two packs are {3, 5}, totaling 2.

Constraints:

  • 1 <= T <= 10
  • 1 <= N, M <= 500
  • -10^9 <= arr[i] <= 10^9
  • Time Limit: 1 sec
AnswerBot
4mo

Find total distinct card types and common card types between two packs of cards.

  • Create a set to store distinct card types when combining both packs.

  • Iterate through each pack and add card types to the ...read more

Help your peers!
Select
Add answer anonymously...

ZS Software Developer interview questions & answers

A Software Developer was asked Q. Allocate Books Problem Statement Given an array of integers arr, where arr[i] re...read more
A Software Developer was asked Q. Sort 0 1 2 Problem Statement Given an integer array arr of size 'N' containing o...read more
A Software Developer was asked Q. Reverse Linked List Problem Statement Given a singly linked list of integers, re...read more

Popular interview questions of Software Developer

A Software Developer was asked Q1. Allocate Books Problem Statement Given an array of integers arr, where arr[i] re...read more
A Software Developer was asked Q2. Sort 0 1 2 Problem Statement Given an integer array arr of size 'N' containing o...read more
A Software Developer was asked Q3. Reverse Linked List Problem Statement Given a singly linked list of integers, re...read more
ZS Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits