"Select
interface,
Count(case when issuccessfulpost then 1 end) as post_success,
Count() as postattempt,
ROUND((COUNT(CASE WHEN issuccessfulpost THEN 1 END) * 100 / COUNT()), 2) AS postsuccess_rate
from post where interface like 'Iphone%'
group by 1
order by postsuccessrate desc
`"
Richard B. - "Select
interface,
Count(case when issuccessfulpost then 1 end) as post_success,
Count() as postattempt,
ROUND((COUNT(CASE WHEN issuccessfulpost THEN 1 END) * 100 / COUNT()), 2) AS postsuccess_rate
from post where interface like 'Iphone%'
group by 1
order by postsuccessrate desc
`"See full answer
"-- Write your query here
Select teamid,playerid,top_Score
from(
with high_score as(
select player_id,
max(gamescore) topscore
from scores
group by player_id
)
select team_id,
a.player_id,
top_score,
rank() over(partition by teamid order by topscore desc) rnk
from players a
left join highscore b on b.playerid = a.player_id)
where rnk <=2"
G B. - "-- Write your query here
Select teamid,playerid,top_Score
from(
with high_score as(
select player_id,
max(gamescore) topscore
from scores
group by player_id
)
select team_id,
a.player_id,
top_score,
rank() over(partition by teamid order by topscore desc) rnk
from players a
left join highscore b on b.playerid = a.player_id)
where rnk <=2"See full answer
"Here is my implementation:
select
marketing_channel,
AVG(purchasevalue) as avgpurchase_value
from
attribution
group by marketing_channel
order by avgpurchasevalue DESC
;
There is no need to copy and past the line of code for calculating the average into order by, just Alias is enough because going by the order of execution in sql, Always, order by is executed after executing select clause."
Maliki U. - "Here is my implementation:
select
marketing_channel,
AVG(purchasevalue) as avgpurchase_value
from
attribution
group by marketing_channel
order by avgpurchasevalue DESC
;
There is no need to copy and past the line of code for calculating the average into order by, just Alias is enough because going by the order of execution in sql, Always, order by is executed after executing select clause."See full answer
"Problem Statement: The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2) with F(0) = 1 and F(1) = 1.
The solution is given in the problem statement itself.
If the value of n = 0, return 1.
If the value of n = 1, return 1.
Otherwise, return the sum of data at (n - 1) and (n - 2).
Explanation: The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1.
Java Solution:
public static int fib(int n"
Rishi G. - "Problem Statement: The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2) with F(0) = 1 and F(1) = 1.
The solution is given in the problem statement itself.
If the value of n = 0, return 1.
If the value of n = 1, return 1.
Otherwise, return the sum of data at (n - 1) and (n - 2).
Explanation: The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1.
Java Solution:
public static int fib(int n"See full answer
"function areSentencesSimilar(sentence1, sentence2, similarPairs) {
if (sentence1.length !== sentence2.length) return false;
for (let i=0; i (w1 === word1 && !visited.has(w2)) || (w2 === word1 && !visited.has(w1)));
if (!edge) {
"
Tiago R. - "function areSentencesSimilar(sentence1, sentence2, similarPairs) {
if (sentence1.length !== sentence2.length) return false;
for (let i=0; i (w1 === word1 && !visited.has(w2)) || (w2 === word1 && !visited.has(w1)));
if (!edge) {
"See full answer
"Here is my first shot at it. Please excuse formatting.
To find the maximum depth of the dependencies given a list of nodes, each having a unique string id and a list of subnodes it depends on, you can perform a depth-first search (DFS) to traverse the dependency graph. Here's how you can implement this:
Represent the nodes and their dependencies using a dictionary.
Perform a DFS on each node to find the maximum depth of the dependencies.
Keep track of the maximum depth encountered dur"
Tes d H. - "Here is my first shot at it. Please excuse formatting.
To find the maximum depth of the dependencies given a list of nodes, each having a unique string id and a list of subnodes it depends on, you can perform a depth-first search (DFS) to traverse the dependency graph. Here's how you can implement this:
Represent the nodes and their dependencies using a dictionary.
Perform a DFS on each node to find the maximum depth of the dependencies.
Keep track of the maximum depth encountered dur"See full answer
"Was given 90 minutes with an exhaustive set of requirements to be implemented as a full-stack coding exercise. It was supposed to have a UX, a server and a database to store and retrieve data.
The IDE was supposed to be self-setup before the interview.
The panel asked questions on top of the implementation around decision making from a technical perspective"
Aman G. - "Was given 90 minutes with an exhaustive set of requirements to be implemented as a full-stack coding exercise. It was supposed to have a UX, a server and a database to store and retrieve data.
The IDE was supposed to be self-setup before the interview.
The panel asked questions on top of the implementation around decision making from a technical perspective"See full answer
"-- Write your query here
select
u.userid as userid,
IFNULL(sum(purchase_value), 0) AS LTV
FROM
user_sessions u
JOIN attribution a
ON u.sessionid = a.sessionid
group by
user_id
order by
LTV desc
;
Needs a full join. Wondering why cant we do a left outer join here. All the sessions should have complete data."
Aneesha K. - "-- Write your query here
select
u.userid as userid,
IFNULL(sum(purchase_value), 0) AS LTV
FROM
user_sessions u
JOIN attribution a
ON u.sessionid = a.sessionid
group by
user_id
order by
LTV desc
;
Needs a full join. Wondering why cant we do a left outer join here. All the sessions should have complete data."See full answer
"select
customer_id,
order_date,
orderid as earliestorder_id
from (
select customer_id,
order_date,
order_id,
rownumber() over (partition by customerid, orderdate order by orderdate) as orderrankper_customer
from orders
) sub_table
where orderrankper_customer=1
order by orderdate, customerid;
Standard solution assumed that the orderid indicates which order comes in first. However this is not always the case, and sometime orderid can be random number withou"
Jessica C. - "select
customer_id,
order_date,
orderid as earliestorder_id
from (
select customer_id,
order_date,
order_id,
rownumber() over (partition by customerid, orderdate order by orderdate) as orderrankper_customer
from orders
) sub_table
where orderrankper_customer=1
order by orderdate, customerid;
Standard solution assumed that the orderid indicates which order comes in first. However this is not always the case, and sometime orderid can be random number withou"See full answer
"not sure what's wrong here>
select
a.marketing_channel,
avg(purchasevalue) as avgpurchase_value,
sum(case when a.purchasevalue > 0 then 1 else 0 end) * 1.0 /count(a.sessionid) as conversion_rate
from attribution a
left join usersessions u on a.sessionid = u.session_id
group by a.marketing_channel
order by conversion_rate desc
`"
Shriganesh K. - "not sure what's wrong here>
select
a.marketing_channel,
avg(purchasevalue) as avgpurchase_value,
sum(case when a.purchasevalue > 0 then 1 else 0 end) * 1.0 /count(a.sessionid) as conversion_rate
from attribution a
left join usersessions u on a.sessionid = u.session_id
group by a.marketing_channel
order by conversion_rate desc
`"See full answer
"Binary Search on the array and after than compare the numbers at low and the high pointers whichever is closest is the answer. Because after the binary search low will be pointing to a number which is immediate greater than x and high will be pointing to a number which is immediate lesser than x.
int low = 0;
int high = n-1;
while(low <= high){
int mid = (low + high) / 2;
if(x == arr[mid]) return mid; //if x is already present then it will be the closest
else if(x < arr[mid]) high"
Shashwat K. - "Binary Search on the array and after than compare the numbers at low and the high pointers whichever is closest is the answer. Because after the binary search low will be pointing to a number which is immediate greater than x and high will be pointing to a number which is immediate lesser than x.
int low = 0;
int high = n-1;
while(low <= high){
int mid = (low + high) / 2;
if(x == arr[mid]) return mid; //if x is already present then it will be the closest
else if(x < arr[mid]) high"See full answer
"-- The text of the task is a bit confusing. If the status is repeated several
-- times, then in the end you should show as start_date the date of the first
-- occurrence, and in end_date the date of the last occurrence of this status,
-- and not the date of the beginning of the next status
with t1 as (select
order_id,
status,
orderdate as startdate,
lead(orderdate) over (partition by orderid order by orderdate) as enddate,
ifnull(lag(status) over (partition by order_id order by or"
Alexey T. - "-- The text of the task is a bit confusing. If the status is repeated several
-- times, then in the end you should show as start_date the date of the first
-- occurrence, and in end_date the date of the last occurrence of this status,
-- and not the date of the beginning of the next status
with t1 as (select
order_id,
status,
orderdate as startdate,
lead(orderdate) over (partition by orderid order by orderdate) as enddate,
ifnull(lag(status) over (partition by order_id order by or"See full answer