"/*
You are with your friends in a castle, where there are multiple rooms named after flowers. Some of the rooms contain treasures - we call them the treasure rooms.
Each room contains a single instruction that tells you which room to go to next.
* instructions1 and treasurerooms_1 *
lily* --------- daisy sunflower
| | |
v v v
jasmin --> tulip* violet* ----> rose* -->
^ | ^ ^ |
"
Azeezat R. - "/*
You are with your friends in a castle, where there are multiple rooms named after flowers. Some of the rooms contain treasures - we call them the treasure rooms.
Each room contains a single instruction that tells you which room to go to next.
* instructions1 and treasurerooms_1 *
lily* --------- daisy sunflower
| | |
v v v
jasmin --> tulip* violet* ----> rose* -->
^ | ^ ^ |
"See full answer
"#simple solution
1.firstly find the node in the bst (O(logn) time complexity it take)
2.now removing the node consists of 3 cases:
1.if the node is leaf (no children):
(keep track of parent and do)
parent.left or parent.right=NULL
simply remove the node ()
2.if(has one child) replace the node with its child
3.if has both childs
we replace the node with either inorder predesor(max of left tree)or inorder succesor and remove
the node wh"
Sambangi C. - "#simple solution
1.firstly find the node in the bst (O(logn) time complexity it take)
2.now removing the node consists of 3 cases:
1.if the node is leaf (no children):
(keep track of parent and do)
parent.left or parent.right=NULL
simply remove the node ()
2.if(has one child) replace the node with its child
3.if has both childs
we replace the node with either inorder predesor(max of left tree)or inorder succesor and remove
the node wh"See full answer
"Use a representative of each, e.g. sort the string and add it to the value of a hashmap> where we put all the words that belong to the same anagram together."
Gaston B. - "Use a representative of each, e.g. sort the string and add it to the value of a hashmap> where we put all the words that belong to the same anagram together."See full answer
Software Engineer
Coding
+4 more
🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.
"SELECT d.name as departmentname,e.id as employeeid,e.firstname,e.lastname,MAX(e.salary) as salary
FROM employees e LEFT JOIN departments d
ON e.department_id=d.id
GROUP BY department_name
ORDER BY department_name;"
Anisha S. - "SELECT d.name as departmentname,e.id as employeeid,e.firstname,e.lastname,MAX(e.salary) as salary
FROM employees e LEFT JOIN departments d
ON e.department_id=d.id
GROUP BY department_name
ORDER BY department_name;"See full answer
"First thing the interviewee did wrong is not asking clarifying questions. This is the most vague problem I have every heard, and the interviewee just made assumptions and started programming."
Nicholas S. - "First thing the interviewee did wrong is not asking clarifying questions. This is the most vague problem I have every heard, and the interviewee just made assumptions and started programming."See full answer
"we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"
Kishor J. - "we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"See full answer
"class Node:
def init(self, value):
self.value = value
self.children = []
def inorder_traversal(root):
if not root:
return []
result = []
n = len(root.children)
for i in range(n):
result.extend(inorder_traversal(root.children[i]))
if i == n // 2:
result.append(root.value)
if n == 0:
result.append(root.value)
return result
Example usage:
root = Node(1)
child1 = Node(2)
chil"
Teddy Y. - "class Node:
def init(self, value):
self.value = value
self.children = []
def inorder_traversal(root):
if not root:
return []
result = []
n = len(root.children)
for i in range(n):
result.extend(inorder_traversal(root.children[i]))
if i == n // 2:
result.append(root.value)
if n == 0:
result.append(root.value)
return result
Example usage:
root = Node(1)
child1 = Node(2)
chil"See full answer
"Traverse the array of points while computing the distance and pushing it to the heap. Then traverse again the heap and pop the k closest. Time O(nlogn) Space O(n)"
Dadja Z. - "Traverse the array of points while computing the distance and pushing it to the heap. Then traverse again the heap and pop the k closest. Time O(nlogn) Space O(n)"See full answer
"Started by asking clarification questions regarding design constraints and desired features.
Break down the into re-usable components - HeroImg and Carousel (with 3 images rendered)
Code the components and managed the state for both in the parent component."
Akshay J. - "Started by asking clarification questions regarding design constraints and desired features.
Break down the into re-usable components - HeroImg and Carousel (with 3 images rendered)
Code the components and managed the state for both in the parent component."See full answer
"A recursive backtracking solution in python.
def changeSigns(nums: List[int], S: int) -> int:
res = []
n = len(nums)
def backtrack(index, curr, arr):
if curr == S and len(arr) == n:
res.append(arr[:])
return
if index >= len(nums):
return
for i in range(index, n):
add +ve number
arr.append(nums[i])
backtrack(i+1, curr + nums[i], arr)
arr.pop()
"
Yugaank K. - "A recursive backtracking solution in python.
def changeSigns(nums: List[int], S: int) -> int:
res = []
n = len(nums)
def backtrack(index, curr, arr):
if curr == S and len(arr) == n:
res.append(arr[:])
return
if index >= len(nums):
return
for i in range(index, n):
add +ve number
arr.append(nums[i])
backtrack(i+1, curr + nums[i], arr)
arr.pop()
"See full answer
"class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
temp = [nums[0]]
for num in nums:
if temp[-1]< num:
temp.append(num)
else:
index = bisect_left(temp,num)
temp[index] = num
return len(temp)
"
Mahima M. - "class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
temp = [nums[0]]
for num in nums:
if temp[-1]< num:
temp.append(num)
else:
index = bisect_left(temp,num)
temp[index] = num
return len(temp)
"See full answer
"Idea for solution:
Reverse the complete char array
Reverse the words separated by space. i.e. Find the space characters and the reverse the subarray between two space characters.
vector reverseSubarray(vector& arr, int s, int e)
{
while (s reverseWords(vector& arr )
{
int n = arr.size();
reverse(arr, 0, n - 1"
Rahul M. - "Idea for solution:
Reverse the complete char array
Reverse the words separated by space. i.e. Find the space characters and the reverse the subarray between two space characters.
vector reverseSubarray(vector& arr, int s, int e)
{
while (s reverseWords(vector& arr )
{
int n = arr.size();
reverse(arr, 0, n - 1"See full answer
"SELECT
u.user_id,
u.user_name,
u.email,
ROUND(AVG(CASE WHEN b.status = 'Unmatched' THEN 1.0 ELSE 0 END), 2) AS avgunmatchedbookings
FROM
users u
LEFT JOIN
bookings b ON u.userid = b.userid
GROUP BY
u.user_id,
u.user_name,
u.email;
`"
Akshay D. - "SELECT
u.user_id,
u.user_name,
u.email,
ROUND(AVG(CASE WHEN b.status = 'Unmatched' THEN 1.0 ELSE 0 END), 2) AS avgunmatchedbookings
FROM
users u
LEFT JOIN
bookings b ON u.userid = b.userid
GROUP BY
u.user_id,
u.user_name,
u.email;
`"See full answer
"Required output in the solution not the one requested from the question. only customerid, firstname, last_name and years were required. Please this needs to be very clear.
Otherwise my answer is
with totalorderyear as (
SELECT
o.customer_id,
c.first_name,
c.last_name,
EXTRACT(YEAR FROM o.orderdate) AS orderyear,
COUNT(o.orderid) AS totalorders
FROM orders o
LEFT JOIN customers c
ON c.customerid = o.customerid
GROUP BY o.customerid, c.firstname, c.last"
Gloriose H. - "Required output in the solution not the one requested from the question. only customerid, firstname, last_name and years were required. Please this needs to be very clear.
Otherwise my answer is
with totalorderyear as (
SELECT
o.customer_id,
c.first_name,
c.last_name,
EXTRACT(YEAR FROM o.orderdate) AS orderyear,
COUNT(o.orderid) AS totalorders
FROM orders o
LEFT JOIN customers c
ON c.customerid = o.customerid
GROUP BY o.customerid, c.firstname, c.last"See full answer