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 || 💯💯💯✅✅✅🔥🔥🔥
- Get link
- X
- Other Apps
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]: matches only one upper or lower case letter in this sequence.[a-zA-Z0-9._-]*: matches zero or more letter of upper or lower case letter, digit, underscore, period, or dash.@leetcode\\.com: matches the string @leetcode.com, where the backslash is used to escape the period character.
Finally, This SQL query returns all rows from the Users table
- the mail column starts with a letter ^[a-zA-Z],
- followed by zero or more occurrences of letters, digits, underscores, periods, or dashes, [a-zA-Z0-9._-]*
- ends with @leetcode.com , '@leetcode\.com'
This satisfies the condition of a valid email address
SQL Query :-
SELECT *
FROM Users
WHERE mail REGEXP '^[a-zA-Z][a-zA-Z0-9._-]*@leetcode\\.com' ;Popular posts from this blog
C++ || STL || standard template libraries
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...
HOW TO PREPARE FOR JEE MAINS IN HOME EFFECTIVELY
Here are some tips given by your senior yaswanth to prepare for JEE mains effectively in home it self At first you should know all things about the examination. You should pay attention in class You should develop speed and accuracy You should be honest with your work Self analysis must be there You should believe in yourself and you should be confident with your studies 1. KNOW ALL THINGS ABOUT EXAM This exam is conducted all over India who are going to join engineering. This is conducted by NTA . This exam is conducted twice a year in January and April. PATTERN: The question paper contains 90 multiple choice questions in which 30 are from maths 30 are from physics and 30 are from chemistry. In my view you should con...
c program to clear nth bit of the number || Bitwise Operators || Problem Solving ||
#include <stdio.h> int main() { int num, n, newNum; printf("Enter any number: "); scanf("%d", &num); printf("Enter nth bit to clear (0-31): "); scanf("%d", &n); newNum = num & (~(1 << n)); printf("Number before clearing %d bit: %d (in decimal)\n", n, num); printf("Number after clearing %d bit: %d (in decimal)\n", n, newNum); return 0; } Logic :- num&(~(1<<n));
Comments
Post a Comment