## apurohit.in

BAN USER- 1of 1 vote

AnswersPrint all subset of a given set which sums up to ZERO

- apurohit.in in India

{8,3,5,1,-4,-8}

so ans will be : {8,-8}

{3,5,-8}

{3,1,-4}

size of set can be upto 50 but elemet of set can be as big as 18 digit number| Report Duplicate | Flag | PURGE

Amazon Dev Lead Dev Lead Algorithm - 0of 0 votes

AnswersHi ,

- apurohit.in in India

Given a set of number eg {5,3,1,8, -8,-4}

Print all subset which will sum up to ZERO

for eg {3,1,-4} {5,3,-8}, {8,-8}

Note : size of subset can be max 100 and element can be very big like 13 or 14 digit number| Report Duplicate | Flag | PURGE

Amazon Dev Lead Dev Lead Algorithm

- 0 Answers
**Maximum number in array after M operations**Given an array numbered from 1 to N, you need to perform M operations. Each operation is described by 3 values a, b and k. Now, k is added for the range of values starting from index 'a' and ending at index 'b' in the given array. Now, After M operations, you have to calculate the maximum of the values in the array.

- apurohit.in January 19, 2016

Initialize the array to '0' before starting to perform M operations.

Consider the number of elements (N) = 5

Number of operations to perform (M) = 4

When M=1,

a=1, b=2, k=100

When M=2,

a=2, b=5, k=100

When M=3,

a=3, b=4, k=100

Initially the array is 0 0 0 0 0

First operation 100 100 0 0 0

Second operation 100 200 100 100 100

Third operation 100 200 200 200 100

ANS 200| Flag | PURGE - 0 Answers
**Check if graph is connected**Hi all I want to my method to return true if two node of un directed graph is connected,

- apurohit.in May 09, 2015

Method print yes its connected but return false ?

public static boolean isConnectedGraph(int[][] graph, int start, int end,

int visited[]) {

visited[start] = 1;

if (graph[start][end] == 1) {

System.out.println("yes its connected ....");

return true;

}

for (int i = 0; i < graph[0].length; i++) {

if (graph[start][i] == 1 && visited[i] == 0) {

visited[i] =1;

isConnectedGraph(graph, i, end, visited);

}

}

return false;

}| Flag | PURGE

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window