"If 0's aren't a concern, couldn't we just
multiply all numbers.
and then divide product by each number in the list ?
if there's more than one zero, then we just return an array of 0s
if there's one zero, then we just replace 0 with product and rest 0s.
what am i missing?"
Sachin R. - "If 0's aren't a concern, couldn't we just
multiply all numbers.
and then divide product by each number in the list ?
if there's more than one zero, then we just return an array of 0s
if there's one zero, then we just replace 0 with product and rest 0s.
what am i missing?"See full answer
"Situation - A time when I worked well on a team was while I was working with the larger team at Blade to do the redesign before their IPO. Essentially, we had a month to launch a redesign (both visual and UX) of the entire project
Task - I was tasked to direct all design efforts and strategy for the mobile and web experience on blade - being a lead in the trifecta group.
Action - Through effective teamwork, we all led strategy and championed our areas of product, design and engineering. As a"
Ben G. - "Situation - A time when I worked well on a team was while I was working with the larger team at Blade to do the redesign before their IPO. Essentially, we had a month to launch a redesign (both visual and UX) of the entire project
Task - I was tasked to direct all design efforts and strategy for the mobile and web experience on blade - being a lead in the trifecta group.
Action - Through effective teamwork, we all led strategy and championed our areas of product, design and engineering. As a"See full answer
"function findPrimes(n) {
if (n < 2) return [];
const primes = [];
for (let i=2; i <= n; i++) {
const half = Math.floor(i/2);
let isPrime = true;
for (let prime of primes) {
if (i % prime === 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.push(i);
}
}
return primes;
}
`"
Tiago R. - "function findPrimes(n) {
if (n < 2) return [];
const primes = [];
for (let i=2; i <= n; i++) {
const half = Math.floor(i/2);
let isPrime = true;
for (let prime of primes) {
if (i % prime === 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.push(i);
}
}
return primes;
}
`"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
"class ListNode:
def init(self, val=0, next=None):
self.val = val
self.next = next
def has_cycle(head: ListNode) -> bool:
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False
debug your code below
node1 = ListNode(1)
node2 = ListNode(2)
node3 = ListNode(3)
node4 = ListNode(4)
creates a linked list with a cycle: 1 -> 2 -> 3 -> 4"
Anonymous Roadrunner - "class ListNode:
def init(self, val=0, next=None):
self.val = val
self.next = next
def has_cycle(head: ListNode) -> bool:
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False
debug your code below
node1 = ListNode(1)
node2 = ListNode(2)
node3 = ListNode(3)
node4 = ListNode(4)
creates a linked list with a cycle: 1 -> 2 -> 3 -> 4"See full answer
Software Engineer
Data Structures & Algorithms
+4 more
🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.
"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
"Lyft mission.
What do we mean by engagement here? We want higher rides , not just time spent on app. What does social mean? When we create interactions between riders. Lyft line is social.
Ideas:
Idea: Can we maintain interactions between riders by letting them ride with same people again? Benefit: Increases repeat rides.
Idea: Giving riders an option to request a driver they rode with. Benefits: Increases social interaction between riders and drivers. Increases retention and # rides as"
M N. - "Lyft mission.
What do we mean by engagement here? We want higher rides , not just time spent on app. What does social mean? When we create interactions between riders. Lyft line is social.
Ideas:
Idea: Can we maintain interactions between riders by letting them ride with same people again? Benefit: Increases repeat rides.
Idea: Giving riders an option to request a driver they rode with. Benefits: Increases social interaction between riders and drivers. Increases retention and # rides as"See full answer
"This is an interesting Favorite Product question. Normally when we're asked this question we pick technology products, but this time the interviewer wanted to throw us a curveball by asking about a non-technical product. Don't worry - it still follows the same approach:
Choose a product and briefly explain what it is
Who are the users?
What are their pain points?
How did competitors solve it in the past?
**How does this product address these pain points differe"
Exponent - "This is an interesting Favorite Product question. Normally when we're asked this question we pick technology products, but this time the interviewer wanted to throw us a curveball by asking about a non-technical product. Don't worry - it still follows the same approach:
Choose a product and briefly explain what it is
Who are the users?
What are their pain points?
How did competitors solve it in the past?
**How does this product address these pain points differe"See full answer
"public static void sortBinaryArray(int[] array) {
int len = array.length;
int[] res = new int[len];
int r=len-1;
for (int value : array) {
if(value==1){
res[r]= 1;
r--;
}
}
System.out.println(Arrays.toString(res));
}
`"
Nitin P. - "public static void sortBinaryArray(int[] array) {
int len = array.length;
int[] res = new int[len];
int r=len-1;
for (int value : array) {
if(value==1){
res[r]= 1;
r--;
}
}
System.out.println(Arrays.toString(res));
}
`"See full answer
"It is very easy to shy away and not make a decision because you might feel the right information is not there to make a decision
While dealing with ambiguity it is essential to remain Calm. And Establish what it is you want to achieve by asking a lot of questions to the necessary stakeholders
Access the risk, analyze the data at hand, ask the right questions, and be very clear and concise in decision-making"
Satish murthy D. - "It is very easy to shy away and not make a decision because you might feel the right information is not there to make a decision
While dealing with ambiguity it is essential to remain Calm. And Establish what it is you want to achieve by asking a lot of questions to the necessary stakeholders
Access the risk, analyze the data at hand, ask the right questions, and be very clear and concise in decision-making"See full answer
"Hey Grandma, you've had a lot of experience with infants, haven't you? When they were babies, you taught them how to chew in their first six months. This initial phase is like giving them data. Once they learned how to chew, they could handle any food you gave them. Next, you refined their learning by teaching them that they should only chew on food. This is like refining the data so they understand what is relevant. Then, a few months later, they started crawling and walking, learning by observ"
Hari priya K. - "Hey Grandma, you've had a lot of experience with infants, haven't you? When they were babies, you taught them how to chew in their first six months. This initial phase is like giving them data. Once they learned how to chew, they could handle any food you gave them. Next, you refined their learning by teaching them that they should only chew on food. This is like refining the data so they understand what is relevant. Then, a few months later, they started crawling and walking, learning by observ"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
"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