This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
void match(const string& s, const string& t, int idxs, int idxt, int& matches) { | |
if (idxt == t.size()) { | |
matches++; | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create table If Not Exists Employee (Id int, Name varchar(255), Salary int, ManagerId int); | |
insert into Employee (Id, Name, Salary, ManagerId) values ('1', 'Joe', '70000', '3'); | |
insert into Employee (Id, Name, Salary, ManagerId) values ('2', 'Henry', '80000', '4'); | |
insert into Employee (Id, Name, Salary, ManagerId) values ('3', 'Sam', '60000', NULL); | |
insert into Employee (Id, Name, Salary, ManagerId) values ('4', 'Max', '90000', NULL); | |
SELECT Emp.Name As Employee | |
FROM Employee As Emp, Employee As Manager | |
WHERE Emp.ManagerId = Manager.Id AND | |
Emp.Salary > Manager.Salary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create table If Not Exists Person (Id int, Email varchar(255)); | |
insert into Person (Id, Email) values ('1', 'a@b.com'); | |
insert into Person (Id, Email) values ('2', 'c@d.com'); | |
insert into Person (Id, Email) values ('3', 'a@b.com'); | |
SELECT Email FROM ( | |
SELECT Email, Count(Email) As Cnt | |
FROM Person | |
GROUP By Email) As CountsTable | |
WHERE Cnt > 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create table If Not Exists Employee (Id int, Name varchar(255), Salary int, DepartmentId int); | |
Create table If Not Exists Department (Id int, Name varchar(255)); | |
insert into Employee (Id, Name, Salary, DepartmentId) values ('1', 'Joe', '85000', '1'); | |
insert into Employee (Id, Name, Salary, DepartmentId) values ('2', 'Henry', '80000', '2'); | |
insert into Employee (Id, Name, Salary, DepartmentId) values ('3', 'Sam', '60000', '2'); | |
insert into Employee (Id, Name, Salary, DepartmentId) values ('4', 'Max', '90000', '1'); | |
insert into Employee (Id, Name, Salary, DepartmentId) values ('5', 'Janet', '69000', '1'); | |
insert into Employee (Id, Name, Salary, DepartmentId) values ('6', 'Randy', '85000', '1'); | |
insert into Employee (Id, Name, Salary, DepartmentId) values ('7', 'Will', '70000', '1'); | |
insert into Department (Id, Name) values ('1', 'IT'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write your MySQL query statement below | |
SELECT Person.FirstName, Person.LastName, Address.City, Address.State | |
FROM Person | |
LEFT JOIN Address | |
ON Person.PersonId = Address.PersonId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//leetcode supplied function (I've created an example): | |
bool isBadVersion(int n) { | |
return (n >= 4); | |
} | |
int firstBadVersion(int n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
bool knows(int a, int b); | |
int findCelebrity(int n) { | |
if (n==0) return -1; | |
int celeb = 0; | |
for (int i=1; i<n; ++i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
bool knows(int a, int b); | |
int findCelebrity(int n) { | |
for (int b=0; b<n; ++b) { | |
int count=0; | |
for (int a=0; a<n; ++n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int numWays(int n, int k) { | |
if (n==0 || k==0) return 0; | |
if (n==1) return k; | |
if (n==2) return k*k; | |
vector<int> dp {0,1,k}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int numWays(int n, int k) { | |
if (n==0 || k==0) return 0; | |
vector<int> dp(n,1); | |
for (int c=1; c<n; ++c) { |
NewerOlder