C ++ code for the above approach
#include <bits/stdc++.h> NEW_LINE using namespace std ; void min_visible_bottles ( int * arr , int n ) { map < int , int > m ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { m [ arr [ i ] ] ++ ; ans = max ( ans , m [ arr [ i ] ] ) ; } cout << " Minimum ▁ number ▁ of ▁ " << " Visible ▁ Bottles ▁ are : ▁ " << ans << endl ; }