"I might be missing something but the solution, seems to be incorrect.
...
, post_pairings AS (
SELECT
ps.user_id,
ps.postseqid AS failpostid,
ps.postseqid + 1 AS nextpostid
FROM post_seq AS ps
WHERE ps.issuccessfulpost IS TRUE
)
-- here ps.issuccessfulpost IS TRUE the condition should be FALSE
-- in that way ps.postseqid is the actual failed post(failpostid)
-- Additionally, at the end the join is assumming that the sequence id is going to match the post_id, wh"
Jaime A. - "I might be missing something but the solution, seems to be incorrect.
...
, post_pairings AS (
SELECT
ps.user_id,
ps.postseqid AS failpostid,
ps.postseqid + 1 AS nextpostid
FROM post_seq AS ps
WHERE ps.issuccessfulpost IS TRUE
)
-- here ps.issuccessfulpost IS TRUE the condition should be FALSE
-- in that way ps.postseqid is the actual failed post(failpostid)
-- Additionally, at the end the join is assumming that the sequence id is going to match the post_id, wh"See full answer
"-- Write your query here
WITH high_value AS(
SELECT user_id
FROM user_sessions
JOIN attribution
ON usersessions.sessionid = attribution.session_id
GROUP BY user_id
HAVING SUM(purchase_value) > 100
ORDER BY SUM(purchase_value) DESC
)
SELECT usersessions.userid, marketing_channel
FROM user_sessions
JOIN high_value
ON usersessions.userid = highvalue.userid
JOIN attribution
ON usersessions.sessionid = attribution.session_id
GROUP BY usersessions.userid
H"
Alina G. - "-- Write your query here
WITH high_value AS(
SELECT user_id
FROM user_sessions
JOIN attribution
ON usersessions.sessionid = attribution.session_id
GROUP BY user_id
HAVING SUM(purchase_value) > 100
ORDER BY SUM(purchase_value) DESC
)
SELECT usersessions.userid, marketing_channel
FROM user_sessions
JOIN high_value
ON usersessions.userid = highvalue.userid
JOIN attribution
ON usersessions.sessionid = attribution.session_id
GROUP BY usersessions.userid
H"See full answer
"You are given a string S and a number K as input, and your task is to print S to console output considering that, at most, you can print K characters per line.
Example:
S = "abracadabra sample"
K = 11
Output:
abracadabra
sample
Note that this problem requires the interviewee gather extra requirements from the interviewer (e.g. do we care about multiple white spaces? what if the length of a word is greater than K, ...)"
B. T. - "You are given a string S and a number K as input, and your task is to print S to console output considering that, at most, you can print K characters per line.
Example:
S = "abracadabra sample"
K = 11
Output:
abracadabra
sample
Note that this problem requires the interviewee gather extra requirements from the interviewer (e.g. do we care about multiple white spaces? what if the length of a word is greater than K, ...)"See full answer
"
from typing import Dict, List, Optional
def max_profit(prices: Dict[str, int]) -> Optional[List[str]]:
pass # your code goes here
max = [None, 0]
min = [None, float("inf")]
for city, price in prices.items():
if price > max[1]:
max[0], max[1] = city, price
if price 0:
return [min[0], max[0]]
return None
debug your code below
prices = {'"
Rick E. - "
from typing import Dict, List, Optional
def max_profit(prices: Dict[str, int]) -> Optional[List[str]]:
pass # your code goes here
max = [None, 0]
min = [None, float("inf")]
for city, price in prices.items():
if price > max[1]:
max[0], max[1] = city, price
if price 0:
return [min[0], max[0]]
return None
debug your code below
prices = {'"See full answer
"I'm pretty sure Exponent's answer is wrong.
In the snippet below, they use "pl.name = 'Telephones' to attempt to filter down to the Telephone transactions, but they do this within a LEFT JOIN which means all product_lines rows are returned.
> LEFT JOIN product_lines pl
> ON p.productlineid = pl.id
> AND pl.name = 'Telephones'
Below is my solution. Also, I didn't see anywhere that said the "amount" column was in cents instead of dollars, but I still divided by 100 to be consistent with Exp"
Bradley E. - "I'm pretty sure Exponent's answer is wrong.
In the snippet below, they use "pl.name = 'Telephones' to attempt to filter down to the Telephone transactions, but they do this within a LEFT JOIN which means all product_lines rows are returned.
> LEFT JOIN product_lines pl
> ON p.productlineid = pl.id
> AND pl.name = 'Telephones'
Below is my solution. Also, I didn't see anywhere that said the "amount" column was in cents instead of dollars, but I still divided by 100 to be consistent with Exp"See full answer
"const ops = {
'+': (a, b) => a+b,
'-': (a, b) => a-b,
'/': (a, b) => a/b,
'': (a, b) => ab,
};
function calc(expr) {
// Search for + or -
for (let i=expr.length-1; i >= 0; i--) {
const char = expr.charAt(i);
if (['+', '-'].includes(char)) {
return opschar), calc(expr.slice(i+1)));
}
}
// Search for / or *
for (let i=expr.length-1; i >= 0; i--) {
const char = expr.charAt(i);
if"
Tiago R. - "const ops = {
'+': (a, b) => a+b,
'-': (a, b) => a-b,
'/': (a, b) => a/b,
'': (a, b) => ab,
};
function calc(expr) {
// Search for + or -
for (let i=expr.length-1; i >= 0; i--) {
const char = expr.charAt(i);
if (['+', '-'].includes(char)) {
return opschar), calc(expr.slice(i+1)));
}
}
// Search for / or *
for (let i=expr.length-1; i >= 0; i--) {
const char = expr.charAt(i);
if"See full answer
"from typing import List
def two_sum(nums: List[int], target: int) -> List[int]:
prevMap = {}
for i, n in enumerate(nums):
diff = target - n
if diff in prevMap:
return [prevMap[diff], i]
else:
prevMap[n] = i
return []
debug your code below
print(two_sum([2, 7, 11, 15], 9))
`"
Anonymous Roadrunner - "from typing import List
def two_sum(nums: List[int], target: int) -> List[int]:
prevMap = {}
for i, n in enumerate(nums):
diff = target - n
if diff in prevMap:
return [prevMap[diff], i]
else:
prevMap[n] = i
return []
debug your code below
print(two_sum([2, 7, 11, 15], 9))
`"See full answer
"
with youngsuccrate as(
select
strftime('%m', postdate) AS postmonth,
round(sum(issuccessfulpost)*1.0/count(issuccessfulpost),2)as yascrate
from
post
where
userid in (select userid from post_user where age between 0 and 18)
group by
post_month
),
nonyoungsucc_rate as(
select
strftime('%m', postdate) AS postmonth,
round(sum(issuccessfulpost)*1.0/count(issuccessfulpost),2)as nonyasc_rate
from
post
where
user_id in (select"
Bhavna S. - "
with youngsuccrate as(
select
strftime('%m', postdate) AS postmonth,
round(sum(issuccessfulpost)*1.0/count(issuccessfulpost),2)as yascrate
from
post
where
userid in (select userid from post_user where age between 0 and 18)
group by
post_month
),
nonyoungsucc_rate as(
select
strftime('%m', postdate) AS postmonth,
round(sum(issuccessfulpost)*1.0/count(issuccessfulpost),2)as nonyasc_rate
from
post
where
user_id in (select"See full answer
"
import pandas as pd
def findaveragedistance(gps_data: pd.DataFrame) -> pd.DataFrame:
#0. IMPORTANT: get the unordered pairs
gpsdata['city1']=gpsdata[['origin','destination']].min(axis=1)
gpsdata['city2']=gpsdata[['origin','destination']].max(axis=1)
#1. get the mean distance by cities
avgdistance=gpsdata.groupby(['city1','city2'], as_index=False)['distance'].mean().round(2)
avgdistance.rename(columns={'distance':"averagedistance"}, inplace=True)
"
Sean L. - "
import pandas as pd
def findaveragedistance(gps_data: pd.DataFrame) -> pd.DataFrame:
#0. IMPORTANT: get the unordered pairs
gpsdata['city1']=gpsdata[['origin','destination']].min(axis=1)
gpsdata['city2']=gpsdata[['origin','destination']].max(axis=1)
#1. get the mean distance by cities
avgdistance=gpsdata.groupby(['city1','city2'], as_index=False)['distance'].mean().round(2)
avgdistance.rename(columns={'distance':"averagedistance"}, inplace=True)
"See full answer
"It depends on the size of the dataset. You want enough samples in both the testing, training and evaluation sets. If there is enough data, 70/20/10 is a good split"
Jasmine Y. - "It depends on the size of the dataset. You want enough samples in both the testing, training and evaluation sets. If there is enough data, 70/20/10 is a good split"See full answer
"Yes, I need to compare the first half of the first string with the reverse order of the second half of the second string. Repeat this process to the first half of the second string and the second half of the first string."
Anonymous Condor - "Yes, I need to compare the first half of the first string with the reverse order of the second half of the second string. Repeat this process to the first half of the second string and the second half of the first string."See full answer
"Use an index, two pointers, and a set to keep track of elements that you've seen.
pseudo code follows:
for i, elem in enumerate(array):
if elem in set return False
if i > N:
set.remove(array[i-N])"
Michael B. - "Use an index, two pointers, and a set to keep track of elements that you've seen.
pseudo code follows:
for i, elem in enumerate(array):
if elem in set return False
if i > N:
set.remove(array[i-N])"See full answer