"function longestCommonPrefix(arr1, arr2) {
const prefixSet = new Set();
for (let num of arr1) {
let str = num.toString();
for (let i = 1; i <= str.length; i++) {
prefixSet.add(str.substring(0, i));
}
}
let longestPrefix = "";
for (let num of arr2) {
let str = num.toString();
for (let i = 1; i <= str.length; i++) {
let prefix = str.substring(0, i);
if (prefixSet.has(prefix)) {
"
Maykon henrique D. - "function longestCommonPrefix(arr1, arr2) {
const prefixSet = new Set();
for (let num of arr1) {
let str = num.toString();
for (let i = 1; i <= str.length; i++) {
prefixSet.add(str.substring(0, i));
}
}
let longestPrefix = "";
for (let num of arr2) {
let str = num.toString();
for (let i = 1; i <= str.length; i++) {
let prefix = str.substring(0, i);
if (prefixSet.has(prefix)) {
"See full answer
"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
"i responded using a multi sourced BFS and in place marking, then i checked the final grid to see if any free spots were left unmarked."
Sh R. - "i responded using a multi sourced BFS and in place marking, then i checked the final grid to see if any free spots were left unmarked."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.
"select e.firstname as firstname,
m.salary as manager_salary
from employees e join employees m on e.manager_id = m.id
where e.salary > m.salary;
`"
Ravi K. - "select e.firstname as firstname,
m.salary as manager_salary
from employees e join employees m on e.manager_id = m.id
where e.salary > m.salary;
`"See full answer
"Requirements and Goals
Primary Goal:Store key-value pairs in a cache with efficient access (reads/writes).
Evict items based on a certain “rank,” which might reflect popularity, frequency, or custom ranking logic.
Functional Requirements:Put(key, value, rank): Insert or update a key with the given value and rank.
Get(key): Retrieve the value associated with the key if it exists.
Evict(): If the cache is at capacity, evict the item with the lowest rank (or according"
Alvis F. - "Requirements and Goals
Primary Goal:Store key-value pairs in a cache with efficient access (reads/writes).
Evict items based on a certain “rank,” which might reflect popularity, frequency, or custom ranking logic.
Functional Requirements:Put(key, value, rank): Insert or update a key with the given value and rank.
Get(key): Retrieve the value associated with the key if it exists.
Evict(): If the cache is at capacity, evict the item with the lowest rank (or according"See full answer
"\# An program that prints out the peak elements in a list of integers.
Pseudocode:
1. Define a function that takes a list of integers as input.
2. Initialize an empty list to store the peak elements.
3. Loop through the list of integers.
4. For each element, check if it is greater than its neighbors.
5. If it is, add it to the list of peak elements.
6. Return the list of peak elements.
def findpeakelements(nums):
if not nums:
return []
peaks = []
n = len(nums"
Frederick K. - "\# An program that prints out the peak elements in a list of integers.
Pseudocode:
1. Define a function that takes a list of integers as input.
2. Initialize an empty list to store the peak elements.
3. Loop through the list of integers.
4. For each element, check if it is greater than its neighbors.
5. If it is, add it to the list of peak elements.
6. Return the list of peak elements.
def findpeakelements(nums):
if not nums:
return []
peaks = []
n = len(nums"See full answer
"Since the problem asks for a O(logN) solution, I have to assume that the numbers are already sorted, meaning the same number are adjacent to each other, the value of the numbers shouldn't matter, and they expect us to use Binary Search.
First, we should analyze the pattern of a regular number array without a single disrupter.
Index: 0 1 2 3 4. 5 6. 7. 8. 9
Array:[1, 1, 2, 2, 4, 4, 5, 5, 6, 6]
notice the odd indexes are always referencing the second of the reoccurring numbers and t"
Bamboo Y. - "Since the problem asks for a O(logN) solution, I have to assume that the numbers are already sorted, meaning the same number are adjacent to each other, the value of the numbers shouldn't matter, and they expect us to use Binary Search.
First, we should analyze the pattern of a regular number array without a single disrupter.
Index: 0 1 2 3 4. 5 6. 7. 8. 9
Array:[1, 1, 2, 2, 4, 4, 5, 5, 6, 6]
notice the odd indexes are always referencing the second of the reoccurring numbers and t"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
"Constraints: 4-direction moves; no mode switching (pick exactly one of {1=bicycle, 2=bike, 3=car, 4=bus} for the full trip).
Per-mode search:
If a mode’s per-step time/cost are uniform, run BFS on allowed cells. Then totaltime = steps × timeperstep, tie-break by steps × costper_step.
If time/cost vary by cell (given matrices), run Dijkstra per mode minimizing (totaltime, totalcost) lexicographically. Maintain the best ⟨time, cost⟩ per cell; relax when the new pair is strictly better.
S"
Rahul J. - "Constraints: 4-direction moves; no mode switching (pick exactly one of {1=bicycle, 2=bike, 3=car, 4=bus} for the full trip).
Per-mode search:
If a mode’s per-step time/cost are uniform, run BFS on allowed cells. Then totaltime = steps × timeperstep, tie-break by steps × costper_step.
If time/cost vary by cell (given matrices), run Dijkstra per mode minimizing (totaltime, totalcost) lexicographically. Maintain the best ⟨time, cost⟩ per cell; relax when the new pair is strictly better.
S"See full answer
"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