Posts

Showing posts from May, 2023

C++ || STL || standard template libraries

Image
                                       C++ STL  1.      Pair :  Syntax :      pair <int,char> p1;     it creates a pair {2,'c'} like this.           pair <int,int> p2;     it creates a pair {2,3} like this .  Basic Code :  #include <bits/stdc++.h> using namespace std; int main() {     // cout<<"hello world\n";     pair <int,int> p1 = {1,2};     cout<<p1.first<< " "<< p1.second<<endl;          pair <int, pair<int ,char>> p2 = {1,{2,'c'}};     cout<<p2.first<<" "<<p2.second.first<<" "<<p2.second.second<<endl;          pair <int,int> arr[] = {{2,3},{4,5},{6,7}};     cout...

Row with maximum ones || Leetcode Solution || Simple Approach || 🔥🔥🔥💯💯💯✅✅✅||

                                                         2643.   Row With Maximum Ones  Link for Question :-  https://leetcode.com/problems/row-with-maximum-ones/description/ Solution :- Solving this problem using dictionary concept: Approach Of solving the problem :  Create a empty dictionary d = {} , initialise count = 0 , lst = [] Iterate over the mat list, now add dictionary for its index and count from the dictionary find the maximum value and store it in v_max variable Now iterate over the dictionary using .items() method Check condition if(value == v_max) append the key and value to the list and terminate the loop now, return the list Complexity Time complexity:  O ( n )       Since we used for loops  Code in Python: class Solution : def rowAndMaximumOnes ( self...