"I work at a startup that makes software for Law Enforcement and the FBI. Our product analyzes calls being made by prison inmates and "listens" for predictors of violence and criminal behavior. Our clients are some of the top state prisons in the country.
Recently one of the largest states in the country decided to evaluate our product for their prison system. I demo'd the product to the officers and they seemed to like everything. During the presentation they asked us if the product was ADA com"
Aabid S. - "I work at a startup that makes software for Law Enforcement and the FBI. Our product analyzes calls being made by prison inmates and "listens" for predictors of violence and criminal behavior. Our clients are some of the top state prisons in the country.
Recently one of the largest states in the country decided to evaluate our product for their prison system. I demo'd the product to the officers and they seemed to like everything. During the presentation they asked us if the product was ADA com"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
"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
"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
"#include
// Naive method to find a pair in an array with a given sum
void findPair(int nums[], int n, int target)
{
// consider each element except the last
for (int i = 0; i < n - 1; i++)
{
// start from the i'th element until the last element
for (int j = i + 1; j < n; j++)
{
// if the desired sum is found, print it
if (nums[i] + nums[j] == target)
{
printf("Pair found (%d, %d)\n", nums[i], nums[j]);
return;
}
}
}
// we reach here if the pair is not found
printf("Pair not found");
}
"
Gundala tarun,cse2020 V. - "#include
// Naive method to find a pair in an array with a given sum
void findPair(int nums[], int n, int target)
{
// consider each element except the last
for (int i = 0; i < n - 1; i++)
{
// start from the i'th element until the last element
for (int j = i + 1; j < n; j++)
{
// if the desired sum is found, print it
if (nums[i] + nums[j] == target)
{
printf("Pair found (%d, %d)\n", nums[i], nums[j]);
return;
}
}
}
// we reach here if the pair is not found
printf("Pair not found");
}
"See full answer
Data Scientist
Data Structures & Algorithms
+5 more
🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.
"from typing import List
def traprainwater(height: List[int]) -> int:
if not height:
return 0
l, r = 0, len(height) - 1
leftMax, rightMax = height[l], height[r]
res = 0
while l < r:
if leftMax < rightMax:
l += 1
leftMax = max(leftMax, height[l])
res += leftMax - height[l]
else:
r -= 1
rightMax = max(rightMax, height[r])
"
Anonymous Roadrunner - "from typing import List
def traprainwater(height: List[int]) -> int:
if not height:
return 0
l, r = 0, len(height) - 1
leftMax, rightMax = height[l], height[r]
res = 0
while l < r:
if leftMax < rightMax:
l += 1
leftMax = max(leftMax, height[l])
res += leftMax - height[l]
else:
r -= 1
rightMax = max(rightMax, height[r])
"See full answer