C # code for the above approach
using System ; using System . Collections . Generic ; class GFG { static void min_visible_bottles ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } ans = Math . Max ( ans , mp [ arr [ i ] ] ) ; } Console . Write ( " Minimum ▁ number ▁ of ▁ " + " Visible ▁ Bottles ▁ are : ▁ " + ans + " STRNEWLINE " ) ; }