shaileshagarwal1
BAN USER
- 1of 1 vote
AnswersDesign an Email sender, need to send 100,000000 emails and you have 5 machines how could you do it efficiently.
- shaileshagarwal1 in India for Transportation Team| Report Duplicate | Flag | PURGE
Amazon SDE-2 Software Design - 0of 0 votes
AnswerGiven an URL you need to analyze all the images( they may be in 1000’s of number) and return the cumulative quality of images present in that url.
- shaileshagarwal1 in India for Transportation Team
lets say: you can configure image quality as very good, good, average, poor..etc, so you have to return one value among them.The given URL may contain several other URLs and they also contain lot of images . you need to consider all of them. lot of questions like how to avoid visiting same url again,
how would you determine the quality of an image if you encounter an url that contains only an image..etc.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Software Design - 0of 0 votes
AnswersDesign Elevator system. And then write an algorithm for that Design such that, the user request should be completed in logN time in a N story building with M elevators.
- shaileshagarwal1 in India for Transportation Team| Report Duplicate | Flag | PURGE
Amazon SDE-2 Software Design - 0of 0 votes
AnswerIn an online teaching system, there are n number of teachers and each one teaches only one subject to any number of students.
- shaileshagarwal1 in India for Transportation Team
And a student can join to any number of teachers to learn those subjects.
And each student can give one preference through which he can get updates about the subject or class timings etc.
Those preferences can be through SMS or twitter/facebook or email..etc.
Design above system and draw the diagram for above.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Software Design
With smallest use of memory and O(n^2) .
- shaileshagarwal1 October 13, 2015public class StringCompress
{
public static String compress(final String source)
{
String str = source;
final StringBuilder sb = new StringBuilder();
int i = 0;
int max = 1;
max = firstSubstringWithoutDuplication(source);
String last = str.substring(i,i+max);
int j=i+1;
i = i+max;
int count = 1;
boolean flag = true;
String current = "";
while (i < str.length())
{
if(i+max<=str.length())
current = str.substring(i,i+max);
else
current = str.substring(i);
if (current.equals(last))
{
count++;
i = i+max;
flag = false;
}
else if(flag)
{
sb.append(count);
sb.append(last.charAt(0));
count = 1;
max = firstSubstringWithoutDuplication(source.substring(j));
if(j+max<=str.length())
last = str.substring(j,j+max);
else
last = str.substring(j);
i=j+max;
j=j+1;
}
else
{
sb.append(count);
sb.append(last);
count = 1;
max = firstSubstringWithoutDuplication(source.substring(i));
last = str.substring(i,i+max);
i=i+max;
}
}
sb.append(count);
sb.append(last);
return sb.toString();
}
public static void main(final String[] args)
{
System.out.println(compress("aab"));
System.out.println(compress("aasasatb"));
System.out.println(compress("abcdbcdff"));
System.out.println(compress("xyzabcdbcdff"));
}
public static int firstSubstringWithoutDuplication(String str) {
int maxLength = 1;
int checker = 0;
for (int i = 0; i < str.length(); i++) {
int val = str.charAt(i) - 'a';
if ((checker & (1 << val)) > 0){ return i; }
checker |= (1 << val);
}
return maxLength;
}
}
Yes they can send emails simultaneously and machines having equal processing power.
- shaileshagarwal1 June 15, 2015
Reprichardcstrong, Accountant at AppPerfect
I am a modern magician, except I transform complicated technical ideas into user-friendly images before the eyes of your company ...
Repirenedpisano, Blockchain Developer at ABC TECH SUPPORT
Hello, I am Irene and I live in Pittsburgh, USA. I am working as A production worker and my duty ...
RepRobin Strain, Consultant
I am from New york. I am 26 year old. I work in a Central Hardware as a Worker compensation ...
RepShayneLJohnson, Scientific Officer at Cerberus Capital
I'm Shayne and I have a history of sensitivities that range from dietary issues to skin care and other ...
RepJennyReimer, Dev Lead at Adobe
Badminton lover, coffee addict, guitarist, International Swiss style practitioner and TDC honorary member. Acting at the nexus of simplicity and ...
Repjasonmcarrier, Analyst at Abs india pvt. ltd.
Hello, I live in Houston and I am working as a Convention planner in Roberd's company, I also part ...
Replillymartin, Senior Software Development Engineer at Aristocrat Gaming
Fashion Designing is the best platform to showcase your talent.Degree in fashion design at Fashion Academy Rotterdam.I am ...
Repsujijaa565, AT&T Customer service email at ABC TECH SUPPORT
My name is suji. I am working as a Suadela Investment in Tulsa USA . I identify and establish a new ...
Repfredlhenry, Android Engineer at Digital Merkating
Hi, I am Fred, 27 years old, I have done bachelor’s in IT.I have been working for a ...
RepNatalieLutz, Applications Developer at Absolute Softech Ltd
Pitch trending story topics and continually look for ways to push breaking and/or viral stories forward with new angles ...
Repsuejnagel, Virus Researcher at Email Customer Service
Hello, I am Sue . I am a chief information officer at Vernon. I am responsible for providing the global communications ...
RepEdithJHarden, Random at Axiom Sources
Je suis un professionnel de la gestion des soins de santé avec 2 ans d'expérience en supervision d'établissements ...
Rephallieriddic, HR Executive Trainee at Barclays Capital
I am Hallie, Dedicated and experienced administrative secretary who excels at prioritizing , completing multiple tasks simultaneously and following through to ...
RepWilliamDGiles, Cloud Support Associate at ADP
Spent 2001-2006 creating marketing channels for tar worldwide. Was quite successful at building tobacco for farmers. Won several awards for ...
RepSoccer lover, coffee addict, guitarist, International Swiss style practitioner and TDC honorary member. Acting at the nexus of simplicity and ...
Repjosephcday6, Android Engineer at Absolute Softech Ltd
I am SEO Executive in Elek-Tek company. I live in Morgantown USA. I won’t write any details about Best ...
Rephollymclark8, Apple Phone Number available 24/7 for our Customers at Accenture
I am clinical laboratory technologist in Stratapro company. I have Excellent clinical laboratory skills, with commended performance conducting/analyzing laboratory ...
Repnyladsomerville, abc
Want to purchase best quality silencer at affordable price manufactured by top most trusted brand Innovative Arms.
Contact Stonefirearms now!
Repmarierlewis2, AT&T Customer service email at ASAPInfosystemsPvtLtd
I am Marie and I live in Los Angeles USA, I have a strong base in marketing and I believe ...
RepSarahSKelly, Game Programmer at Akamai
I am Professor, and I am also a skilled fiction writer. I have a collection of novels published in the ...
Repjohnlevans657, Principal Software Engineer at Ask.com
Hi, I am John, from Taxes USA, I am a dedicated, extremely organized, and highly competent Administrative Specialist seeking a ...
Repvictorcraigw, Animator at Chicago Mercantile Exchange
Hi, I am Victor working as a Speech Writer in the USA. Spoke at an academic conference about mantra for ...
RepHenryMelvin, Korean Air Change Flight at AMD
Hello, everybody! My name is Henry,I am a picture-drawer.Art drawing & painting classes for adults, kids, teens.We have ...
Open Chat in New Window
class GasStation {
- shaileshagarwal1 June 26, 2016public static int canCompleteCircuit(int[] gas, int[] cost) {
if(gas == null || cost == null) return -1;
int total = 0;
int upToNow = 0;
int startPos = 0;
for(int i=0; i<gas.length; i++) {
int delta = gas[i] - cost[i];
if(upToNow >= 0) upToNow += delta;
else {
upToNow = delta;
startPos = i;
}
total += delta;
}
return total >= 0 ? startPos : -1;
}
public static void main(String[] args) {
int[] gas = {3,5,7};
int[] cost = {8,4,3};
System.out.println(canCompleteCircuit(gas, cost));
}
}