mohit
BAN USER
- 1of 1 vote
AnswersGiven an array arr and a number n, you have to find whether there exist a subset in arr whose sum is n. You have to print length of the subset.
- mohit in India
1. There exists only one subset like that
2. All number in arr are positive| Report Duplicate | Flag | PURGE
Amazon SDE1 Dynamic Programming - 0of 0 votes
AnswersSuppose you are a stock trader and you can do as many trades but if you stop you can't do another trade. You can start with any trade. Given an array of profits/loss of trades and find the maximum profit you can make.
Input:
Number of trades
Profit/loss in each trade
Output:
Max Profit
Ex:
Input:7 1 2 3 4 -2 -3 1
Output:
10
Explaination: Trade of [1,2,3,4]
Input:5 -2 -3 -4 1 2
Output:
3
P.S: Any solution than Brute-Force.
- mohit in India| Report Duplicate | Flag | PURGE
Nagarro Intern - 0of 0 votes
AnswersGiven two integer arrays A and B.
B contains exactly same numbers as A except two additional numbers. Find the two elements with minimum time and space complexity.
for ex: A ={1, 4, 2, 6, 3}
B = {4, 0,7, 6, 3, 2, 1}
ans: 0 7
I came with this solution:
- mohit in United StatesArrays.sort(A); Arrays.sort(B); int i=0, j=0; while(j<=i+2 || i<A.length){ if(A[i]==B[j]){ ++i; ++j} else{ System.out.println(b[j]); j++; } } if(j==A.length+1){ System.out.println(B[j++]+" "B[j]); } if(j==B.length) System.out.println)(B[j]);
| Report Duplicate | Flag | PURGE
Alcatel Lucent - 0of 0 votes
AnswersGiven an input n, find the smallest number x such that x % n = 0 and sum of the digits in x is equal to n.
- mohit in India
Note: x is so large even long long int can't keep it.
It is obvious that find the sum of digits using (x/10) gives timeout, so how can its complexity be reduced.| Report Duplicate | Flag | PURGE
1 Answer Algorithms
Given an input n, find the smallest number x such that x % n = 0 and sum of the digits in x is equal to n.
- mohit September 22, 2014
Note: x is so large even long long int can't keep it.
It is obvious that find the sum of digits using (x/10) gives timeout, so how can its complexity be reduced.| Flag | PURGE
Repnickjonson885, Consultant at ASU
I am Department director in a Libera company. I live in Buffalo NY, USA. I am a hard worker girl ...
Repkristinedavila9, Android Engineer at ABC TECH SUPPORT
I am Kristine Davila Professor and director at Clinical Psychology. Having experience of 6 years in my career. I have ...
Repharoldjmaloney, Accountant at ASU
Hi, I am a Computer systems administrator from texas. Experienced in running a wide variety of software development Company. Looking ...
Repjoankelly306, Site Manager at EFI
Hi, I am Joan from Fairbanks, in USA. I have been a Food Product Manager in a Food Barn Company ...
RepAmberBrook, Animator at A9
Hi everyone, Done my master of arts in specialized journalism.Also an member of society of professional journalists since 2015 ...
Repkennypmillerk, AT&T Customer service email at 247quickbookshelp
My name is Kenny and I am working as a trusted investor in Pittsburgh USA.I identify / set up a ...
Repamayalopez800, Accountant at A9
I am Amaya ,working in the field of training and development coordinator for three years, focusing on teaching English as ...
Reppamilarbowman, Animator at ABC TECH SUPPORT
Je travaille en tant que Web Manager dans la société Forum Cafeterias. Je veux tout savoir sur le marketing numérique ...
Radix sort is for strings
- mohit December 25, 2014