"import java.util.Arrays;
import java.util.stream.Collectors;
class Main
{
// Recursive function to print all combinations of numbers from \i\ to \n\
// having sum \n. The index\ denotes the next free slot in the output array \out\
public static void printCombinations(int i, int n, int[] out, int index)
{
// if the sum becomes n, print the combination
if (n == 0)
{
System.out.println(Arrays.stream(out).limit(index)
.boxed().collect(Collectors.toList()));
}
// start from the previous e"
Relynn may silver B. - "import java.util.Arrays;
import java.util.stream.Collectors;
class Main
{
// Recursive function to print all combinations of numbers from \i\ to \n\
// having sum \n. The index\ denotes the next free slot in the output array \out\
public static void printCombinations(int i, int n, int[] out, int index)
{
// if the sum becomes n, print the combination
if (n == 0)
{
System.out.println(Arrays.stream(out).limit(index)
.boxed().collect(Collectors.toList()));
}
// start from the previous e"See full answer
"function constructTree(n, matrix) {
let parent = [];
let child = [];
let root = null;
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
if (matrixi === 1) {
parent.push(i);
child.push(j);
}
}
}
for (let i = 0; i < n; i++) {
if (parent.indexOf(i) === -1) {
root = i;
}
}
let node = new Node(root);
for (let i = 0; i < n; i++) {
if (i !== root) {
constructTreeUtil(node, parent[i], child[i]);
}
}
return node;
}"
Ugo C. - "function constructTree(n, matrix) {
let parent = [];
let child = [];
let root = null;
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
if (matrixi === 1) {
parent.push(i);
child.push(j);
}
}
}
for (let i = 0; i < n; i++) {
if (parent.indexOf(i) === -1) {
root = i;
}
}
let node = new Node(root);
for (let i = 0; i < n; i++) {
if (i !== root) {
constructTreeUtil(node, parent[i], child[i]);
}
}
return node;
}"See full answer
"The height of a binary tree is the maximum number of edges from the root node to any leaf node. To calculate the height of a binary tree, we can use a recursive approach. The basic idea is to compare the heights of the left and right subtrees of the root node, and return the maximum of them plus one."
Prashant Y. - "The height of a binary tree is the maximum number of edges from the root node to any leaf node. To calculate the height of a binary tree, we can use a recursive approach. The basic idea is to compare the heights of the left and right subtrees of the root node, and return the maximum of them plus one."See full answer
"String commonStr(String str1, String str2) {
int len1 = str1.length();
int len2 = str2.length();
if (len1 == 0 || len2 == 0) return "";
// let dpx reprsent the longest common str of 0...x
int dp = new int len1 + 1;
int maxLen = 0;
int endIndex = 0;
for (int i = 1; i <= len1; i++) {
for (int j = 1; j <= len2; j++) {
if (str1.charAt(i-1) == str2.charAt(j-1)) {
dpi = dpi-1 + 1;
"
Emma X. - "String commonStr(String str1, String str2) {
int len1 = str1.length();
int len2 = str2.length();
if (len1 == 0 || len2 == 0) return "";
// let dpx reprsent the longest common str of 0...x
int dp = new int len1 + 1;
int maxLen = 0;
int endIndex = 0;
for (int i = 1; i <= len1; i++) {
for (int j = 1; j <= len2; j++) {
if (str1.charAt(i-1) == str2.charAt(j-1)) {
dpi = dpi-1 + 1;
"See full answer
"My brute force approach was to read them. Give a id to each paragraph and for each token count the number of time it has appeared. If any two rows look same , it is duplicated. Further , interviewer guided me that he will do it with hashing."
Payal B. - "My brute force approach was to read them. Give a id to each paragraph and for each token count the number of time it has appeared. If any two rows look same , it is duplicated. Further , interviewer guided me that he will do it with hashing."See full answer