"def findAlibaba(countOfRooms, strategy):
#countofrooms: num rooms
#listRooms rooms to look for alibabba
possiblePlaces = []
#initialize rooms
for i in range(countOfRooms):
possiblePlaces.append(True)
for i in range(len(strategy)):
roomToCheck = strategy[i]
#Room is marked as unavailable
possiblePlaces[roomToCheck] = False
#Next day calculatins
nextDayPlaces = []
for j in range(countOfRooms):
nextDayPla"
JOBHUNTER - "def findAlibaba(countOfRooms, strategy):
#countofrooms: num rooms
#listRooms rooms to look for alibabba
possiblePlaces = []
#initialize rooms
for i in range(countOfRooms):
possiblePlaces.append(True)
for i in range(len(strategy)):
roomToCheck = strategy[i]
#Room is marked as unavailable
possiblePlaces[roomToCheck] = False
#Next day calculatins
nextDayPlaces = []
for j in range(countOfRooms):
nextDayPla"See full answer
"Determine the requirements
Perform basic checks on the frontend before submitting to the server
Length
Check for invalid or required characters
Client-side validation messaging
Perform more advanced checks on the server if required
Does the password include the user's name, etc
Handle server-side validation messaging"
Casey C. - "Determine the requirements
Perform basic checks on the frontend before submitting to the server
Length
Check for invalid or required characters
Client-side validation messaging
Perform more advanced checks on the server if required
Does the password include the user's name, etc
Handle server-side validation messaging"See full answer
"this task is misleading . i used lag(1) and lead(1) cuz it did not say "compare temperature from 2 days before and 1 day before" , it reads to me as if its asking "compare cur temperature to prev and future and see if it rose and fall""
Erjan G. - "this task is misleading . i used lag(1) and lead(1) cuz it did not say "compare temperature from 2 days before and 1 day before" , it reads to me as if its asking "compare cur temperature to prev and future and see if it rose and fall""See full answer
"with var1
as (select *,
rank() over(order by score desc) as srank
from players)
select player_name, score, srank as ranking
from var1
where srank in (4, 6, 11)
`"
Bryan L. - "with var1
as (select *,
rank() over(order by score desc) as srank
from players)
select player_name, score, srank as ranking
from var1
where srank in (4, 6, 11)
`"See full answer
"SELECT
e1.empid AS manageremployee_id,
e1.empname AS managername,
COUNT(e2.empid) AS numberofdirectreports
FROM employees AS e1
INNER JOIN employees AS e2
ON e2.managerid = e1.empid
GROUP BY e1.emp_id
HAVING COUNT(e2.emp_id) >= 2
ORDER BY numberofdirectreports DESC, managername ASC
`"
Alvin P. - "SELECT
e1.empid AS manageremployee_id,
e1.empname AS managername,
COUNT(e2.empid) AS numberofdirectreports
FROM employees AS e1
INNER JOIN employees AS e2
ON e2.managerid = e1.empid
GROUP BY e1.emp_id
HAVING COUNT(e2.emp_id) >= 2
ORDER BY numberofdirectreports DESC, managername ASC
`"See full answer
"import random
def coin_flip():
x=4*[0]+[1]
res=[]
for i in range(20):
res.append(random.choice(x))
return res
res=[0,0] # [head,tail]
for j in range(1000):
temp=coin_flip()
res[0]+=sum(temp) #head
res[1]+=(20-sum(temp)) #tail"
Alireza K. - "import random
def coin_flip():
x=4*[0]+[1]
res=[]
for i in range(20):
res.append(random.choice(x))
return res
res=[0,0] # [head,tail]
for j in range(1000):
temp=coin_flip()
res[0]+=sum(temp) #head
res[1]+=(20-sum(temp)) #tail"See full answer
"SELECT
p1.player_name AS player1,
p2.player_name AS player2,
ABS(p1.level - p2.level) AS level_disparity
FROM
players p1
JOIN
players p2 ON p1.playername < p2.playername
WHERE
ABS(p1.level - p2.level) <= 5
ORDER BY
level_disparity ASC;"
Jayveer S. - "SELECT
p1.player_name AS player1,
p2.player_name AS player2,
ABS(p1.level - p2.level) AS level_disparity
FROM
players p1
JOIN
players p2 ON p1.playername < p2.playername
WHERE
ABS(p1.level - p2.level) <= 5
ORDER BY
level_disparity ASC;"See full answer
"SELECT COUNT(DISTINCT o.customerid) AS customers, d.departmentname
FROM orders o
INNER JOIN departments d
ON d.departmentid = o.departmentid
WHERE d.departmentname IN ('Electronics','Fashion') AND o.orderdate BETWEEN '2022-01-01' AND '2022-12-31'
GROUP BY d.department_name;
`"
Derrick M. - "SELECT COUNT(DISTINCT o.customerid) AS customers, d.departmentname
FROM orders o
INNER JOIN departments d
ON d.departmentid = o.departmentid
WHERE d.departmentname IN ('Electronics','Fashion') AND o.orderdate BETWEEN '2022-01-01' AND '2022-12-31'
GROUP BY d.department_name;
`"See full answer
"Definitely nice to think of this without memorization, but there is a well known algorithm for this problem, which is the Levenshtein Distance.
Lev(a,b) = len(a) if len(b) == 0
= len(b) if len(a) == 0
= lev(a[1:], b[1:] if a[0] == b[0]
= 1 + min (lev(a, b[1:]), lev(a[1:], b), lev(a[1:], b[1:]))
https://en.wikipedia.org/wiki/Levenshtein_distance
I'm sure some optimizations could be made with heuristic."
Nicholas S. - "Definitely nice to think of this without memorization, but there is a well known algorithm for this problem, which is the Levenshtein Distance.
Lev(a,b) = len(a) if len(b) == 0
= len(b) if len(a) == 0
= lev(a[1:], b[1:] if a[0] == b[0]
= 1 + min (lev(a, b[1:]), lev(a[1:], b), lev(a[1:], b[1:]))
https://en.wikipedia.org/wiki/Levenshtein_distance
I'm sure some optimizations could be made with heuristic."See full answer