Posts

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...

Find Users With Valid E-Mails || Leetcode sql solution || Easy solution || Fully-Explained || 💯💯💯✅✅✅🔥🔥🔥

Image
  1517 .   Find Users With Valid E-Mails Write an SQL query to find the users who have  valid emails . A valid e-mail has a prefix name and a domain where: The prefix name  is a string that may contain letters (upper or lower case), digits, underscore  '_' , period  '.' , and/or dash  '-' . The prefix name  must  start with a letter. The domain  is  '@leetcode.com' . Return the result table in  any order . The query result format is in the following example. Fully-Explained Solution : To write SQL query for selecting all rows from the Users table where the mail column to match with a regular expression pattern that describes a valid email address with has the domain @leetcode.com. REGEXP :- It is the sequence of characters that specifies a match pattern in text Approach :- The regular expression pattern  should contain '^[a-zA-Z][a-zA-Z0-9._-]*@leetcode\\.com' ^  : specifies the starting charater of string [a-zA-Z] : ...

Reformat Department Table || Leetcode SQL solution || easy & simplest solution || ✅✅✅💯💯💯🔥🔥🔥

Image
                           1179 .   Reformat Department Table Write an SQL query to reformat the table such that there is a department id column and a revenue column  for each month . Return the result table in  any order . The query result format is in the following example. Detailed Solution: # Write your MySQL query statement below select id , sum ( if ( month = "Jan" , revenue , null ) ) as Jan_Revenue , sum ( if ( month = "Feb" , revenue , null ) ) as Feb_Revenue , sum ( if ( month = 'Mar' , revenue , null ) ) as Mar_Revenue , sum ( if ( month = 'Apr' , revenue , null ) ) as Apr_Revenue , sum ( if ( month = 'May' , revenue , null ) ) as May_Revenue , sum ( if ( month = 'Jun' , ...