Skip to main content

TCS

TCS OA-17 2024

Problem Description

A person owns a collection of shoes, where each shoe has both a size and a side (either left "L" or right "R"). Each shoe is represented in the form of a string, sizeSide, where size is an integer indicating the shoe size, and side is a character ('L' or 'R') indicating whether it’s a left or right shoe.
Your task is to calculate the total number of pairs of shoes that can be formed. A pair consists of one left shoe and one right shoe of the same size.

Input Format

  • The first line contains an integer N, representing the array's length.
  • The second line contains N space-separated strings representing the size and side of a shoe.

Output Format

An integer representing the total number of pairs of shoes that can be formed.

Constraints

  • 1 ≤ arr.size() ≤ 100
  • 1 ≤ arr[i] ≤ 50

Example

Sample Input:

6
shoes = ["6L", "6R", "7L", "6R", "7R", "6R"]

Sample Output:

2

Explanation:

There are two pairs: one pair of size 6 (matching "6L" and "6R") and one pair of size 7 (matching "7L" and "7R").