"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
"1) create the experimental and control groups.
2) Then calculate the proportion (mean) of the true conversion rates for both groups using the convert column which counts True as 1 and False as 0. This is their conversion rates
3) calculate the statistic of the two groups by subtracting the proportion and standardizing.
4) get the p-value and compare with 0.05.
5) conclude the difference is statistically significant if the p-value is less than 0.05 otherwise no statistical difference"
Frank A. - "1) create the experimental and control groups.
2) Then calculate the proportion (mean) of the true conversion rates for both groups using the convert column which counts True as 1 and False as 0. This is their conversion rates
3) calculate the statistic of the two groups by subtracting the proportion and standardizing.
4) get the p-value and compare with 0.05.
5) conclude the difference is statistically significant if the p-value is less than 0.05 otherwise no statistical difference"See full answer
"While running the testloop I am getting an error RuntimeError: runningmean should contain 28 elements not 38.
I think it's the difference between the categorical features in train and test.
`"
Abinash S. - "While running the testloop I am getting an error RuntimeError: runningmean should contain 28 elements not 38.
I think it's the difference between the categorical features in train and test.
`"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
"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
Software Engineer
Coding
+1 more
🧠Want an expert answer to a question? Saving questions lets us know what content to make next.
"`#include
using namespace std;
void printNumbersTillN(int n){
if(n_==0){
return;
}
printNumbersTillN(n-1); // go to the end -> reach 1
cout>_n;
printNumbersTillN(n);
}`"
Jet 1. - "`#include
using namespace std;
void printNumbersTillN(int n){
if(n_==0){
return;
}
printNumbersTillN(n-1); // go to the end -> reach 1
cout>_n;
printNumbersTillN(n);
}`"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
"-- LTV = Sum of all purchases made by that user
-- order the results by desc on LTV
select
u.user_id,
sum(a.purchase_value) as LTV
from
user_sessions u
join
attribution a
on u.sessionid = a.sessionid
group by
u.user_id
order by sum(a.purchase_value) desc"
Mohit C. - "-- LTV = Sum of all purchases made by that user
-- order the results by desc on LTV
select
u.user_id,
sum(a.purchase_value) as LTV
from
user_sessions u
join
attribution a
on u.sessionid = a.sessionid
group by
u.user_id
order by sum(a.purchase_value) desc"See full answer
"A much better solution than the one in the article, below:
It looks like the ones writing articles here in Javascript do not understand the time/space complexity of javascript methods.
shift, splice, sort, etc... In the solution article you have a shift and a sort being done inside a while, that is, the multiplication of Ns.
My solution, below, iterates through the list once and then sorts it, separately. It´s O(N+Log(N))
class ListNode {
constructor(val = 0, next = null) {
th"
Guilherme F. - "A much better solution than the one in the article, below:
It looks like the ones writing articles here in Javascript do not understand the time/space complexity of javascript methods.
shift, splice, sort, etc... In the solution article you have a shift and a sort being done inside a while, that is, the multiplication of Ns.
My solution, below, iterates through the list once and then sorts it, separately. It´s O(N+Log(N))
class ListNode {
constructor(val = 0, next = null) {
th"See full answer
"SELECT order_amount
FROM
(SELECT
o.order_amount,
DENSERANK() OVER (ORDER BY o.orderamount DESC) as rnk
FROM orders o
JOIN departments d ON d.departmentid = o.departmentid
WHERE d.department_name = 'Fashion'
)
WHERE rnk = 2"
Ankit P. - "SELECT order_amount
FROM
(SELECT
o.order_amount,
DENSERANK() OVER (ORDER BY o.orderamount DESC) as rnk
FROM orders o
JOIN departments d ON d.departmentid = o.departmentid
WHERE d.department_name = 'Fashion'
)
WHERE rnk = 2"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
"-- filter for december and november data
-- the total order amount per depatment per month
-- department, month, order_amount
with monthly_orders AS (
SELECT
department_id,
strftime('%m', order_date) AS month,
SUM(orderamount) AS orderamount
FROM
orders
WHERE
orderdate >= '2022-11-01' AND orderdate < '2023-01-01'
group by
department_id, month
),
-- -- add difference from this month to last ( use lag )
monthly_comp"
Aneesha K. - "-- filter for december and november data
-- the total order amount per depatment per month
-- department, month, order_amount
with monthly_orders AS (
SELECT
department_id,
strftime('%m', order_date) AS month,
SUM(orderamount) AS orderamount
FROM
orders
WHERE
orderdate >= '2022-11-01' AND orderdate < '2023-01-01'
group by
department_id, month
),
-- -- add difference from this month to last ( use lag )
monthly_comp"See full answer
"we can create 2 sets for rows and columns and store the rows and column having 0 and then just check in a loop if the count of that row is greater than 0 llly for column then put the row and column to zero"
Bhavya V. - "we can create 2 sets for rows and columns and store the rows and column having 0 and then just check in a loop if the count of that row is greater than 0 llly for column then put the row and column to zero"See full answer
"To determine if a graph is not a tree, you can check for the following conditions:
Presence of cycles: A graph is not a tree if it contains cycles. In a tree, there should be exactly one unique path between any two vertices. If you can find a cycle in the graph, it cannot be a tree.
Insufficient number of edges: A tree with N vertices will have exactly N-1 edges. If the graph has fewer or more than N-1 edges, then it is not a tree.
Disconnected components: A tree is a connected graph, m"
Vaibhav C. - "To determine if a graph is not a tree, you can check for the following conditions:
Presence of cycles: A graph is not a tree if it contains cycles. In a tree, there should be exactly one unique path between any two vertices. If you can find a cycle in the graph, it cannot be a tree.
Insufficient number of edges: A tree with N vertices will have exactly N-1 edges. If the graph has fewer or more than N-1 edges, then it is not a tree.
Disconnected components: A tree is a connected graph, m"See full answer
"class Solution:
def missingNumber(self, nums: list[int]) -> int:
Sorting approach
n = len(nums)
s = n*(n+1)//2
r = s - sum(nums)
return self.r
l = [3,0,1]
print(missingNumber(l))"
Rohit B. - "class Solution:
def missingNumber(self, nums: list[int]) -> int:
Sorting approach
n = len(nums)
s = n*(n+1)//2
r = s - sum(nums)
return self.r
l = [3,0,1]
print(missingNumber(l))"See full answer