Alex works at a clothing store. There is a large pile of socks that must be paired by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are n=7 socks with colors ar = {1,2,1,2,1,3,2). There is one pair of color 1 and one of color 2. There are three odd socks left, one of each color. The number of pairs is 2. Function Description Complete the sockMerchant function in the editor below. It must return an integer representing the number of matching pairs of socks that are available. sockMerchant has the following parameter(s): n: the number of socks in the pile ar: the colors of each sock Input Format The first line contains an integer n, the number of socks represented in ar. The second line contains n space-separated integers describing the colors ar[i] of the socks in the pile. Constraints 1 <= n <= 100 1 <= ar[i]<= 100 & 0 <=i
Alex works at a clothing store. There is a large pile of socks that must be paired by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are n=7 socks with colors ar = {1,2,1,2,1,3,2). There is one pair of color 1 and one of color 2. There are three odd socks left, one of each color. The number of pairs is 2. Function Description Complete the sockMerchant function in the editor below. It must return an integer representing the number of matching pairs of socks that are available. sockMerchant has the following parameter(s): n: the number of socks in the pile ar: the colors of each sock Input Format The first line contains an integer n, the number of socks represented in ar. The second line contains n space-separated integers describing the colors ar[i] of the socks in the pile. Constraints 1 <= n <= 100 1 <= ar[i]<= 100 & 0 <=i
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
in c++ fast please
![Problem Statement
Alex works at a clothing store. There is a large pile of socks that must be paired by color for sale. Given an array of integers representing the color of each
sock, determine how many pairs of socks with matching colors there are.
For example, there are n=7 socks with colors ar = (1,2,1,2,1,3,2). There is one pair of color 1 and one of color 2. There are three odd socks left, one of each
color. The number of pairs is 2.
Function Description
A
Complete the sockMerchant function in the editor below. It must return an integer representing the number of matching pairs of socks that are available.
sockMerchant has the following parameter(s):
n: the number of socks in the pile
ar: the colors of each sock
Input Format
The first line contains an integer n, the number of socks represented in ar.
The second line contains n space-separated integers describing the colors ar[i] of the socks in the pile.
Constraints
1
<= n <= 100
1 <= ar[i] <= 100 & 0 <=i<n
Output Format
Return the total number of matching pairs of socks that Alex can sell.
Sample Input
9
10 20 20 10 10 30 50 10 20
Sample Output](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa37aa9da-24a4-4f27-9e6f-b91f450ae1f3%2F98908df9-a949-494f-8030-b9c0828efcf0%2Ff6smlr_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Problem Statement
Alex works at a clothing store. There is a large pile of socks that must be paired by color for sale. Given an array of integers representing the color of each
sock, determine how many pairs of socks with matching colors there are.
For example, there are n=7 socks with colors ar = (1,2,1,2,1,3,2). There is one pair of color 1 and one of color 2. There are three odd socks left, one of each
color. The number of pairs is 2.
Function Description
A
Complete the sockMerchant function in the editor below. It must return an integer representing the number of matching pairs of socks that are available.
sockMerchant has the following parameter(s):
n: the number of socks in the pile
ar: the colors of each sock
Input Format
The first line contains an integer n, the number of socks represented in ar.
The second line contains n space-separated integers describing the colors ar[i] of the socks in the pile.
Constraints
1
<= n <= 100
1 <= ar[i] <= 100 & 0 <=i<n
Output Format
Return the total number of matching pairs of socks that Alex can sell.
Sample Input
9
10 20 20 10 10 30 50 10 20
Sample Output
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY