"This was a 60 minute assessment. The clock is ticking and you're being observed by a senior+ level engineer. Be ready to perform for an audience.
The implementation for the system gets broken up into three parts:
Implement creating accounts and depositing money into an account by ID
Implement transferring money with validation to ensure the accounts for the transfer both exist and that the account money is being removed from has enough money in it to perform the transfer
Implement find"
devopsjesus - "This was a 60 minute assessment. The clock is ticking and you're being observed by a senior+ level engineer. Be ready to perform for an audience.
The implementation for the system gets broken up into three parts:
Implement creating accounts and depositing money into an account by ID
Implement transferring money with validation to ensure the accounts for the transfer both exist and that the account money is being removed from has enough money in it to perform the transfer
Implement find"See full answer
"I firstly discuss the brute force approach in O(n^2) time complexity , than i moved to O(nlogn) tine complexity than i discussed the O(n) time complexity and O(n) space complexity . But interviewer want more optimised solution , in O(n) time complexity without using extra space ,
The solution wants O(1) space complexity i have to do changes in same array without using any space . This method is something like i have to place positive values to its original position by swapping and rest negativ"
Anni P. - "I firstly discuss the brute force approach in O(n^2) time complexity , than i moved to O(nlogn) tine complexity than i discussed the O(n) time complexity and O(n) space complexity . But interviewer want more optimised solution , in O(n) time complexity without using extra space ,
The solution wants O(1) space complexity i have to do changes in same array without using any space . This method is something like i have to place positive values to its original position by swapping and rest negativ"See full answer
"
Compare alternate houses i.e for each house starting from the third, calculate the maximum money that can be stolen up to that house by choosing between:
Skipping the current house and taking the maximum money stolen up to the previous house.
Robbing the current house and adding its value to the maximum money stolen up to the house two steps back.
package main
import (
"fmt"
)
// rob function calculates the maximum money a robber can steal
func maxRob(nums []int) int {
ln"
VContaineers - "
Compare alternate houses i.e for each house starting from the third, calculate the maximum money that can be stolen up to that house by choosing between:
Skipping the current house and taking the maximum money stolen up to the previous house.
Robbing the current house and adding its value to the maximum money stolen up to the house two steps back.
package main
import (
"fmt"
)
// rob function calculates the maximum money a robber can steal
func maxRob(nums []int) int {
ln"See full answer
"Batch Packing Problem
In Amazon’s massive warehouse inventory, there are different types of products. You are given an array products of size n, where products[i] represents the number of items of product type i. These products need to be packed into batches for shipping.
The batch packing must adhere to the following conditions:
No two items in the same batch can be of the same product type.
The number of items packed in the current batch must be strictly greater than the number pack"
Anonymous Goat - "Batch Packing Problem
In Amazon’s massive warehouse inventory, there are different types of products. You are given an array products of size n, where products[i] represents the number of items of product type i. These products need to be packed into batches for shipping.
The batch packing must adhere to the following conditions:
No two items in the same batch can be of the same product type.
The number of items packed in the current batch must be strictly greater than the number pack"See full answer
"SELECT customer_id,
order_date,
orderid AS secondearliestorderid
FROM (
SELECT order_id,
customer_id,
order_date,
ROWNUMBER() OVER (PARTITION BY customerid, orderdate ORDER BY orderid ASC) AS rank
FROM orders
)
WHERE rank = 2
ORDER BY orderdate, customerid
`"
Tiffany A. - "SELECT customer_id,
order_date,
orderid AS secondearliestorderid
FROM (
SELECT order_id,
customer_id,
order_date,
ROWNUMBER() OVER (PARTITION BY customerid, orderdate ORDER BY orderid ASC) AS rank
FROM orders
)
WHERE rank = 2
ORDER BY orderdate, customerid
`"See full answer
"SELECT
s.Sale_Date,
SUM(si.Quantity * si.SalePrice) AS TotalRevenue
FROM Sales s
JOIN SaleItems si ON s.SaleID = si.Sale_ID
GROUP BY s.Sale_Date
ORDER BY s.Sale_Date;
"
Bala G. - "SELECT
s.Sale_Date,
SUM(si.Quantity * si.SalePrice) AS TotalRevenue
FROM Sales s
JOIN SaleItems si ON s.SaleID = si.Sale_ID
GROUP BY s.Sale_Date
ORDER BY s.Sale_Date;
"See full answer
"CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·"
Raj V. - "CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·CreditGO Loan App Customer-Care Number =(O)}((+917439822246=))℅+/{+O 9346281901+} CALL Now ·"See full answer
"We can use dictionary to store cache items so that our read / write operations will be O(1).
Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1)
Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"
Alfred O. - "We can use dictionary to store cache items so that our read / write operations will be O(1).
Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1)
Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"See full answer
"-- Write your query here
select
id,
(case
when p_id is null then 'Root'
when pid in (select id from treenode_table)
and id in (select pid from treenode_table) then 'Inner'
else 'Leaf' end) as node_types
from treenodetable
order by 1;
`"
Anonymous Roadrunner - "-- Write your query here
select
id,
(case
when p_id is null then 'Root'
when pid in (select id from treenode_table)
and id in (select pid from treenode_table) then 'Inner'
else 'Leaf' end) as node_types
from treenodetable
order by 1;
`"See full answer
"WITH ActiveUsersYesterday AS (
SELECT DISTINCT user_id
FROM user_activity
WHERE activity_date = CAST(GETDATE() - 1 AS DATE)
),
VideoCallUsersYesterday AS (
SELECT DISTINCT user_id
FROM video_calls
WHERE call_date = CAST(GETDATE() - 1 AS DATE)
)
SELECT
(CAST(COUNT(DISTINCT v.userid) AS FLOAT) / NULLIF(COUNT(DISTINCT a.userid), 0)) * 100 AS percentagevideocall_users
FROM
ActiveUsersYesterday a
LEFT JOIN
VideoCallUsersYesterday v ON a.userid = v.userid;"
Bala G. - "WITH ActiveUsersYesterday AS (
SELECT DISTINCT user_id
FROM user_activity
WHERE activity_date = CAST(GETDATE() - 1 AS DATE)
),
VideoCallUsersYesterday AS (
SELECT DISTINCT user_id
FROM video_calls
WHERE call_date = CAST(GETDATE() - 1 AS DATE)
)
SELECT
(CAST(COUNT(DISTINCT v.userid) AS FLOAT) / NULLIF(COUNT(DISTINCT a.userid), 0)) * 100 AS percentagevideocall_users
FROM
ActiveUsersYesterday a
LEFT JOIN
VideoCallUsersYesterday v ON a.userid = v.userid;"See full answer
"How do you find consecutive days for login (MySQL, SQL, date, subquery, MySQL 5.7, development)?
1
Follow
Request
Answer
More
All related (34)
Recommended
📷
Trausti Thor Johannsson
·
Follow
Been using MySQL for more than 16 yearsDec 27
There are functions like DATEDIFF but there are also BETWE"
Hayatu H. - "How do you find consecutive days for login (MySQL, SQL, date, subquery, MySQL 5.7, development)?
1
Follow
Request
Answer
More
All related (34)
Recommended
📷
Trausti Thor Johannsson
·
Follow
Been using MySQL for more than 16 yearsDec 27
There are functions like DATEDIFF but there are also BETWE"See full answer
"WITH filtered_posts AS (
SELECT
p.user_id,
p.issuccessfulpost
FROM
post p
WHERE
p.postdate >= '2023-11-01' AND p.postdate < '2023-12-01'
),
post_summary AS (
SELECT
pu.user_type,
COUNT(*) AS post_attempt,
SUM(CASE WHEN fp.issuccessfulpost = 1 THEN 1 ELSE 0 END) AS post_success
FROM
filtered_posts fp
JOIN
postuser pu ON fp.userid = pu.user_id
GROUP BY
pu.user_type
)
SELECT
user_type,
post_success,
post_attempt,
CAST(postsuccess AS FLOAT) / postattempt AS postsuccessrate
FROM
po"
David I. - "WITH filtered_posts AS (
SELECT
p.user_id,
p.issuccessfulpost
FROM
post p
WHERE
p.postdate >= '2023-11-01' AND p.postdate < '2023-12-01'
),
post_summary AS (
SELECT
pu.user_type,
COUNT(*) AS post_attempt,
SUM(CASE WHEN fp.issuccessfulpost = 1 THEN 1 ELSE 0 END) AS post_success
FROM
filtered_posts fp
JOIN
postuser pu ON fp.userid = pu.user_id
GROUP BY
pu.user_type
)
SELECT
user_type,
post_success,
post_attempt,
CAST(postsuccess AS FLOAT) / postattempt AS postsuccessrate
FROM
po"See full answer
"#include
#include
#include
using namespace std;
vector diff(const vector& A, const vector& B) {
unordered_set elements;
vector result;
for (const auto& element : A) {
elements.insert(element);
}
for (const auto& element : B) {
if (elements.find(element) == elements.end()) {
result.push_back(element);
} else {
elements.erase(element);
}
}
for"
Warrenbuff - "#include
#include
#include
using namespace std;
vector diff(const vector& A, const vector& B) {
unordered_set elements;
vector result;
for (const auto& element : A) {
elements.insert(element);
}
for (const auto& element : B) {
if (elements.find(element) == elements.end()) {
result.push_back(element);
} else {
elements.erase(element);
}
}
for"See full answer
"Here's a simpler solution:
select
u.username
, count(p.postid) as countposts
from posts as p
join users as u
on p.userid = u.userid
where p.likes >= 100
group by 1
order by 2 desc, 1 asc
limit 3
`"
Bradley E. - "Here's a simpler solution:
select
u.username
, count(p.postid) as countposts
from posts as p
join users as u
on p.userid = u.userid
where p.likes >= 100
group by 1
order by 2 desc, 1 asc
limit 3
`"See full answer
"Question: An array of n integers is given, and a positive integer k, where k << n. k indicates that the absolute difference between each element's current index (icurrent) and the index in the sorted array (isorted) is less than k (|icurr - isorted| < k).
Sort the given array.
The most common solution is with a Heap:
def solution(arr, k):
min_heap = []
result = []
for i in range(len(arr))
heapq.heappush(min_heap, arr[i])
"
Guilherme M. - "Question: An array of n integers is given, and a positive integer k, where k << n. k indicates that the absolute difference between each element's current index (icurrent) and the index in the sorted array (isorted) is less than k (|icurr - isorted| < k).
Sort the given array.
The most common solution is with a Heap:
def solution(arr, k):
min_heap = []
result = []
for i in range(len(arr))
heapq.heappush(min_heap, arr[i])
"See full answer
"Limit and rank() only works if there are no 2 employees with same salary ( which is okay for this use case)
For the query to pass all the test results, we need to use dense_rank
with ranked_employees as
(
select id, firstname, lastname, salary,
denserank() over(order by salary desc) as salaryrank
from employees
)
select id, firstname, lastname, salary from ranked_employees
where salary_rank <= 3
`"
Vysali K. - "Limit and rank() only works if there are no 2 employees with same salary ( which is okay for this use case)
For the query to pass all the test results, we need to use dense_rank
with ranked_employees as
(
select id, firstname, lastname, salary,
denserank() over(order by salary desc) as salaryrank
from employees
)
select id, firstname, lastname, salary from ranked_employees
where salary_rank <= 3
`"See full answer
"Implemented a recursive function which returns the length of the list so far. when the returned value equals k + 1 , assign current.next = current.next.next. If I made it back to the head return root.next as the new head of the linked list."
דניאל ר. - "Implemented a recursive function which returns the length of the list so far. when the returned value equals k + 1 , assign current.next = current.next.next. If I made it back to the head return root.next as the new head of the linked list."See full answer