"Picking the value of 'k' can be little tricky. One simple approach would be to start with elbow method. Try different 'k' values and plot them on a graph like an experiment.
When the graph starts to look like an elbow, that's a good 'k' to pick!
Also keep in mind you may not always have clearly clustered data. The elbow may not be clear and sharp as you expect.
Hope this helps."
Praveen D. - "Picking the value of 'k' can be little tricky. One simple approach would be to start with elbow method. Try different 'k' values and plot them on a graph like an experiment.
When the graph starts to look like an elbow, that's a good 'k' to pick!
Also keep in mind you may not always have clearly clustered data. The elbow may not be clear and sharp as you expect.
Hope this helps."See full answer
"\# Definition for a binary tree node.
class TreeNode:
def init(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def maxPathSum(self, root: TreeNode) -> int:
self.max_sum = float('-inf')"
Jerry O. - "\# Definition for a binary tree node.
class TreeNode:
def init(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def maxPathSum(self, root: TreeNode) -> int:
self.max_sum = float('-inf')"See full answer
"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
"A few months ago I joined a micro-services platform engineering team as their manager, at that time my team was struggling to deliver towards an upcoming production deadline for a customer facing product. Production date had been moved 5 times already and there were about 40% of product features which were remaining to be tested and signed off to move to production . I was made responsible to deliver the release of this product within the deadline and turnaround the software delivery throughput."
Shuchi A. - "A few months ago I joined a micro-services platform engineering team as their manager, at that time my team was struggling to deliver towards an upcoming production deadline for a customer facing product. Production date had been moved 5 times already and there were about 40% of product features which were remaining to be tested and signed off to move to production . I was made responsible to deliver the release of this product within the deadline and turnaround the software delivery throughput."See full answer
"Even more faster and vectorized version, using np.linalg.norm - to avoid loop and np.argpartition to select lowest k. We dont need to sort whole array - we need to be sure that first k elements are lower than the rest.
import numpy as np
def knn(Xtrain, ytrain, X_new, k):
distances = np.linalg.norm(Xtrain - Xnew, axis=1)
k_indices = np.argpartition(distances, k)[:k] # O(N) selection instead of O(N log N) sort
return int(np.sum(ytrain[kindices]) > k / 2.0)
`"
Dinar M. - "Even more faster and vectorized version, using np.linalg.norm - to avoid loop and np.argpartition to select lowest k. We dont need to sort whole array - we need to be sure that first k elements are lower than the rest.
import numpy as np
def knn(Xtrain, ytrain, X_new, k):
distances = np.linalg.norm(Xtrain - Xnew, axis=1)
k_indices = np.argpartition(distances, k)[:k] # O(N) selection instead of O(N log N) sort
return int(np.sum(ytrain[kindices]) > k / 2.0)
`"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
"
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
"My leadership style is flexible and adaptive, it varies depending on the team members and the needs of the company. My leadership goal is to empower the team and inspire and grow leaders. In order to achieve that, I combine transformational, democratic and coaching leadership styles.
Usually when we are facing a new type of challenge, or at the early stage of a project, I like to adapt the transformational leadership which allows me to listen to all the suggestions from the team members and sta"
onering2ruleall - "My leadership style is flexible and adaptive, it varies depending on the team members and the needs of the company. My leadership goal is to empower the team and inspire and grow leaders. In order to achieve that, I combine transformational, democratic and coaching leadership styles.
Usually when we are facing a new type of challenge, or at the early stage of a project, I like to adapt the transformational leadership which allows me to listen to all the suggestions from the team members and sta"See full answer
"
import java.util.*;
class Solution {
// Time Complexity: O(n^2)
// Space Complexity: O(n)
public static List> threeSum(int[] nums) {
// Ensure that the array is sorted first
Arrays.sort(nums);
// Create the results list to return
List> results = new ArrayList();
// Iterate over the length of nums
for (int i = 0; i < nums.length-2; i++) {
// We will have the first number in"
Victor O. - "
import java.util.*;
class Solution {
// Time Complexity: O(n^2)
// Space Complexity: O(n)
public static List> threeSum(int[] nums) {
// Ensure that the array is sorted first
Arrays.sort(nums);
// Create the results list to return
List> results = new ArrayList();
// Iterate over the length of nums
for (int i = 0; i < nums.length-2; i++) {
// We will have the first number in"See full answer
"It might not be a good idea to predict stock prices only based on reddit comments.
You could create a signal from reddit comments that can indicate "social media interest" and feed it into a ML system (along with other features) that predicts prices. Collecting good data to train the model and evaluating it correctly are going to be huge challenges."
Satyajit G. - "It might not be a good idea to predict stock prices only based on reddit comments.
You could create a signal from reddit comments that can indicate "social media interest" and feed it into a ML system (along with other features) that predicts prices. Collecting good data to train the model and evaluating it correctly are going to be huge challenges."See full answer