"from collections import deque
def updateword(words, startword, end_word):
if end_word not in words:
return None # Early exit if end_word is not in the dictionary
queue = deque([(start_word, 0)]) # (word, steps)
visited = set([start_word]) # Keep track of visited words
while queue:
word, steps = queue.popleft()
if word == end_word:
return steps # Found the target word, return steps
for i in range(len(word)):
"
叶 路. - "from collections import deque
def updateword(words, startword, end_word):
if end_word not in words:
return None # Early exit if end_word is not in the dictionary
queue = deque([(start_word, 0)]) # (word, steps)
visited = set([start_word]) # Keep track of visited words
while queue:
word, steps = queue.popleft()
if word == end_word:
return steps # Found the target word, return steps
for i in range(len(word)):
"See full answer
"Reversing a linked list is a very popular question. We have two approaches to reverse the linked list: Iterative approach and recursion approach.
Iterative approach (JavaScript)
function reverseLL(head){
if(head === null) return head;
let prv = null;
let next = null;
let cur = head;
while(cur){
next = cur.next; //backup
cur.next = prv;
prv = cur;
cur = next;
}
head = prv;
return head;
}
Recursion Approach (JS)
function reverseLLByRecursion("
Satyam S. - "Reversing a linked list is a very popular question. We have two approaches to reverse the linked list: Iterative approach and recursion approach.
Iterative approach (JavaScript)
function reverseLL(head){
if(head === null) return head;
let prv = null;
let next = null;
let cur = head;
while(cur){
next = cur.next; //backup
cur.next = prv;
prv = cur;
cur = next;
}
head = prv;
return head;
}
Recursion Approach (JS)
function reverseLLByRecursion("See full answer
"One of the biggest risks I have taken was in a recent product, where we developed a new feature and released the feature externally without QA sign-off.
Feature - Interactive Travel Itinerary Maps
We had about ten days from the time we decided to include this new feature in the external launch. Usually, the biggest chunk of time in each release cycle was the sign-off from an external QA team. We fast-tracked the dev effort and completed the development of the feature in five days. Unfortunately,"
R S. - "One of the biggest risks I have taken was in a recent product, where we developed a new feature and released the feature externally without QA sign-off.
Feature - Interactive Travel Itinerary Maps
We had about ten days from the time we decided to include this new feature in the external launch. Usually, the biggest chunk of time in each release cycle was the sign-off from an external QA team. We fast-tracked the dev effort and completed the development of the feature in five days. Unfortunately,"See full answer
"public static boolean isPalindrome(String str){
boolean flag = true;
int len = str.length()-1;
int j = len;
for(int i=0;i<=len/2;i++){
if(str.charAt(i)!=str.charAt(j--)){
flag = false;
break;
}
}
return flag;
}"
Sravanthi M. - "public static boolean isPalindrome(String str){
boolean flag = true;
int len = str.length()-1;
int j = len;
for(int i=0;i<=len/2;i++){
if(str.charAt(i)!=str.charAt(j--)){
flag = false;
break;
}
}
return flag;
}"See full answer
"Start by explaining your understanding of Google Maps.
It is a free web/mobile-based feature that allows users to
navigate from Point A to B, trip planning
locate restaurants, hair salons, other points of interest around a point on the map
Businesses use to sponsor advertisements based on Map search string.
Clarify what does improvement means, "Improve" is a loaded term - what do we mean by improvement: increased ad revenue, improve the quality of the results, increase downloads, imp"
Rachita D. - "Start by explaining your understanding of Google Maps.
It is a free web/mobile-based feature that allows users to
navigate from Point A to B, trip planning
locate restaurants, hair salons, other points of interest around a point on the map
Businesses use to sponsor advertisements based on Map search string.
Clarify what does improvement means, "Improve" is a loaded term - what do we mean by improvement: increased ad revenue, improve the quality of the results, increase downloads, imp"See full answer
Product Manager
Product Design
🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.
"
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
"I follow a variation of the RICE framework when prioritizing how I ship product features. I start by looking at:
Reach: Because the customer segmentation across our product portfolio is so similar, I tend to hold a lot of weight on product features that will maximize our customer reach with a minimal LOE.
Impact: After establishing which customer segments will benefit from the product feature, I determine the urgency and estimated impact on each customer segment based on customer i"
Ashley C. - "I follow a variation of the RICE framework when prioritizing how I ship product features. I start by looking at:
Reach: Because the customer segmentation across our product portfolio is so similar, I tend to hold a lot of weight on product features that will maximize our customer reach with a minimal LOE.
Impact: After establishing which customer segments will benefit from the product feature, I determine the urgency and estimated impact on each customer segment based on customer i"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
"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
"Interviewer : How would you reduce ride cancellation on Uber ?
Shailesh : Okay before I jump onto the solution, I would like to clarify some points for better understanding. So ride can be cancelled from the both the parties rider and the driver ? So which side are we talking about ?
Interviewer : we are seeing more cancellation from diver side.
Shailesh : From how long we are seeing this trend ?
Interviewer : you can say from an year.
Shailesh : Okay, also are we seeing these cancellations from"
Anonymous Muskox - "Interviewer : How would you reduce ride cancellation on Uber ?
Shailesh : Okay before I jump onto the solution, I would like to clarify some points for better understanding. So ride can be cancelled from the both the parties rider and the driver ? So which side are we talking about ?
Interviewer : we are seeing more cancellation from diver side.
Shailesh : From how long we are seeing this trend ?
Interviewer : you can say from an year.
Shailesh : Okay, also are we seeing these cancellations from"See full answer
"It would have been more interesting to focus on the system design rather than the Trie DS, Interviewee could have just mentioned the Trie and passed to things more important.
Interviewee should have focused on the factors on which he wants to scale the API servers, popularity of the query parts ? region may be ? A hash of many factors ?
Caches should have definitely be discussed, Cache eviction policies, Cache invalidation managements...
Interviewee should have mentioned which kind of API pro"
Aymen D. - "It would have been more interesting to focus on the system design rather than the Trie DS, Interviewee could have just mentioned the Trie and passed to things more important.
Interviewee should have focused on the factors on which he wants to scale the API servers, popularity of the query parts ? region may be ? A hash of many factors ?
Caches should have definitely be discussed, Cache eviction policies, Cache invalidation managements...
Interviewee should have mentioned which kind of API pro"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
"Initialize left pointer: Set a left pointer left to 0.
Iterate through the array: Iterate through the array from left to right.
If the current element is not 0, swap it with the element at the left pointer and increment left.
Time complexity: O(n). The loop iterates through the entire array once, making it linear time.
Space complexity: O(1). The algorithm operates in-place, modifying the input array directly without using additional data structures.
"
Avon T. - "Initialize left pointer: Set a left pointer left to 0.
Iterate through the array: Iterate through the array from left to right.
If the current element is not 0, swap it with the element at the left pointer and increment left.
Time complexity: O(n). The loop iterates through the entire array once, making it linear time.
Space complexity: O(1). The algorithm operates in-place, modifying the input array directly without using additional data structures.
"See full answer
"In python
def find_duplicates(arr1: List[int], arr2: List[int]) -> List[int]:
result = list(set(arr1) & set(arr2))
return result
"
Sammy R. - "In python
def find_duplicates(arr1: List[int], arr2: List[int]) -> List[int]:
result = list(set(arr1) & set(arr2))
return result
"See full answer