"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
"As a PM i received a feedback from my program manager on my style of verbal communication. It is about me speaking faster when i wanted to get away with a topic that i wasn't confident (may be not backed up with data, or still in process of getting detailed insight of a problem etc.). Whereas when I'm confident I tend to speak slowly or more assertively that made people to follow easily.
I welcomed that feedback so from then on when I'm not confident in a topic I became more assertive to let pe"
Rajesh V. - "As a PM i received a feedback from my program manager on my style of verbal communication. It is about me speaking faster when i wanted to get away with a topic that i wasn't confident (may be not backed up with data, or still in process of getting detailed insight of a problem etc.). Whereas when I'm confident I tend to speak slowly or more assertively that made people to follow easily.
I welcomed that feedback so from then on when I'm not confident in a topic I became more assertive to let pe"See full answer
"
from typing import List
def getnumberof_islands(binaryMatrix: List[List[int]]) -> int:
if not binaryMatrix: return 0
rows = len(binaryMatrix)
cols = len(binaryMatrix[0])
islands = 0
for r in range(rows):
for c in range(cols):
if binaryMatrixr == 1:
islands += 1
dfs(binaryMatrix, r, c)
return islands
def dfs(grid, r, c):
if (
r = len(grid)
"
Rick E. - "
from typing import List
def getnumberof_islands(binaryMatrix: List[List[int]]) -> int:
if not binaryMatrix: return 0
rows = len(binaryMatrix)
cols = len(binaryMatrix[0])
islands = 0
for r in range(rows):
for c in range(cols):
if binaryMatrixr == 1:
islands += 1
dfs(binaryMatrix, r, c)
return islands
def dfs(grid, r, c):
if (
r = len(grid)
"See full answer
"Over-fitting of a model occurs when model fails to generalize to any new data and has high variance withing training data whereas in under fitting model isn't able to uncover the underlying pattern in the training data and high bias.
Tree based model like decision tree and random forest are likely to overfit whereas linear models like linear regression and logistic regression tends to under fit.
There are many reasons why a Random forest can overfits easily 1. Model has grown to its full depth a"
Jyoti V. - "Over-fitting of a model occurs when model fails to generalize to any new data and has high variance withing training data whereas in under fitting model isn't able to uncover the underlying pattern in the training data and high bias.
Tree based model like decision tree and random forest are likely to overfit whereas linear models like linear regression and logistic regression tends to under fit.
There are many reasons why a Random forest can overfits easily 1. Model has grown to its full depth a"See full answer
"Deep Learning is a part of Artificial Intelligence, it's like teaching the machine to think and make decisions on its own. It's like how we teach a child the concept of an apple - it's round, red, has a stem on top. We show them multiple pictures of apples and then they understand and can recognize an apple in future. Similarly, we feed lots of data to the machine, and slowly, it starts learning from that data, and can then make relevant predictions or decisions based on what it has learnt.
A co"
Surbhi G. - "Deep Learning is a part of Artificial Intelligence, it's like teaching the machine to think and make decisions on its own. It's like how we teach a child the concept of an apple - it's round, red, has a stem on top. We show them multiple pictures of apples and then they understand and can recognize an apple in future. Similarly, we feed lots of data to the machine, and slowly, it starts learning from that data, and can then make relevant predictions or decisions based on what it has learnt.
A co"See full answer