• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
October 23, 2024 |30 Views

PROBLEM OF THE DAY : 22/10/2024 | Sub-arrays with equal number of occurences

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Ayush Tripathi We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

Given an array arr[] and two integers say, and y, find the number of sub-arrays in which the number of occurrences of x is equal to the number of occurrences of y.

Examples:

Input: arr[] = [1, 2, 1] , x= 1 , y = 2 Output: 2 Explanation: The possible sub-arrays have same equal number of occurrences of x and y are: 1) [1, 2], x and y have same occurrence(1). 2) [2, 1], x and y have same occurrence(1).
 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/sub-arrays-with-equal-number-of-occurences3901/1