shaileshagarwal1
BAN USER
- 18of 18 votes
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
Repellabryan25416, Accountant at A9
Hello, I am a Managing editor. I have completed my studies from New York. Apart from this, whenever I am ...
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 ...
Repkristenjjimenezk, Analyst at ADP
We Statistical assistants establish and check numerical facts in many different areas of business, government, and industry. Right now I ...
Repsophiaddelano, Android Engineer at 247quickbookshelp
Extensive experience setting up, installing, and maintaining a variety of audio equipment. I Work with loudspeakers, amplifiers,microphones, and more ...
RepKatieKate, Developer at Amazon
Katie , a general laborer skilled in construction work, landscaping and trimming, and other commercial and residential tasks. Love to find ...
Replegabesg, Android Engineer at ASU
My name is JoeColeman . I am working at Rite Solution as a Data entry keyer . It's been almost 10 ...
Repdalecronin028, Animator at Pinterest
Hello, I am Dale. I am a Tourist guide who welcomes tourists . Tourist Guides act as ambassadors of the country ...
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 ...
RepDaisyDiaz, abc at ADP
I am enthusiastic professional writer with years of experience in writing articles for magazines and newspaper, very dependable and has ...
RepDustinSeals, Accountant at 247quickbookshelp
I am Dustin . Speech-language pathologist in Standard Brands Paint Company. I diagnose and swallow problems. I work with both children ...
Repangeljperez232, Animator at ADP
Hello,I am a Marketing Manager. And I have 2+ experience in Marketing Manager.I like to read about vashikaran ...
RepRutviLopez, abc at A9
I have demonstrated skills in written communication with multiple award winning pieces and a strong willingness to revise and edit ...
Repolliejshea, Android test engineer at ABC TECH SUPPORT
Hello I am an application engineer. I love my work very much. Nowadays I am doing some new experiments. Like ...
RepSydneyLevy, Area Sales Manager at 247quickbookshelp
I am a highway patrol officerIn the highway patrol is the part of the police force within a particular state ...
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 ...
RepCandiRoy, HR at ASU
I am a qualified CEO with experience in overseeing the daily activities of small businesses and large corporations alike. I ...
Replillymartin, Senior Software Development Engineer at Aristocrat Gaming
Hi everybody! I'm Lilly, a 22 year old girl from Us. Master of economic and financial evaluation of development ...
RepEddieAtkins, Network Engineer at Big Fish
Creative Screenwriter with a passion for storytelling and extraordinary experience of working with world-famous actors and entertainment companies, such as ...
RepSophiaLopez, Analyst at AMD
I am a skilled freelance graphic designer with over a decade of experience in the field. I am dedicated to ...
RepMinnieRuffin, Accountant at Boomerang Commerce
Minnie , a business leader professional accustomed to managing projects with Vashikaran Specialist in nagpur pay after results with fast-paced and ...
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 ...
Repjeannetucker768, Analyst at 247quickbookshelp
Hello I am a computer programmer. I have completed all my studies from New York. Currently I am working in ...
RepIsabellaJones, abc at 8x8
Extensive experience of 3 years in network architecture and application requirements for corporate data and voice networks, planning, designing and ...
Repmeerjahelesan, Backend Developer at Abs india pvt. ltd.
My name is FredHolli. I am working at Warner Brothers Studio Store as a Human resources clerk .I mostly spend ...
RepJanaSmith, Integration Software Engineer at Deloitte Consulting LLP
I am Jana , an order processor with my strong work ethic. My interests are listening to music which helps me ...
RepLaylaMoore, Analyst at ADP
I am a skilled content editor with 3 years of excellent service in the communications field. I developed, researched, and ...
Repmariadbulter222, Android Engineer at ABC TECH SUPPORT
Hey, I am a corporate investigator. I love this work. My hobby like write story and different types of article ...
RepEllaScotz, abc at A9
I am a creative designer with innovative ideas and a unique approach to visuals. I am also a skilled painter ...
RepAngelinaJolly, Member Technical Staff at Bankbazaar
Angelina , a Trustworthy Head Housekeeper with extensive experience in leading a large housekeeping team, hiring and training new staff and ...
Repddmohsi890, Associate at Abs india pvt. ltd.
Working as a Photographic processing machine operator at Cardinal Stores for almost 10 years . I have lots of experience in ...
RepEllaJoni, abc at 8x8
By profession I am an auditing assistant with extensive experience in handling administrative duties and executive responsibilities associated with both ...
RepRosieBell, Accountant at 8x8
I have technical knowledge of multiple camera technologies -Extensive communication, cooperation, and service skills -Critical thinking, analysis, free revenge spells ...
RepPrishaDavin, abc at 8x8
I promote and provide extraordinary internal external guest services, answer questions, offer information, and provide assistance in a courteous manner ...
RepNancy , a Homemaker manages the household of the various families. I love to explore astrology so I recently took help ...
RepShivelyFauver, Animator at AMD
Project Management Assistant with a proven record in developing and managing project budgets, completing presentations and reports. As nowadays astrology ...
Repmargarettdhigginson11, Android Engineer at ABC TECH SUPPORT
Hello I am a content writer. A content writer is an entry-level job role. It is responsible for writing clear ...
RepEvaSanchez, Animator at Abs india pvt. ltd.
Eva , Manufacturing Worker with 3+ years of experience working in Dynatronics . Went for traveling around the world and gets to ...
Replleongardner, Animator at 247quickbookshelp
I am a writer and television producer living in the Corpus Christi area. I have always been fascinated by the ...
Repbrianlwarren596, Android Engineer at 247quickbookshelp
Hey my name is BrainWarren and I am working as an Interpreter.my main work is Interpreters and translators convert ...
RepAasiHarris, abc at 8x8
I am a creative designer with innovative ideas and a unique approach to visuals. I am also a skilled painter ...
Repsuegdiaz765, Android test engineer at 247quickbookshelp
My name is Sue and I am a Specialist. We Specialist employees are responsible for specific tasks or activities in ...
Repsushiswla65, Area Sales Manager at ABC TECH SUPPORT
My name is SarahProctor . I am working as a Video editor at Konsili . I am exploring some magical tricks . vashikaran ...
Repggroverwmiller, Android Engineer at 247quickbookshelp
Hello I am a Budget officer with 5 years of experience. The Budget Officer implements budgeting and financial record keeping ...
RepAadhilDiaz, Accountant at A9
I have a knowledgeable and experienced history professor looking to obtain a position in which to impact students and improve ...
Repopalphelan234, Associate at 247quickbookshelp
I am a specialized Cardiac and vascular nurse at the Circus World . Here I meet different people and observe their ...
Repdeckdella34, Applications Developer at Abs india pvt. ltd.
I am working as a Vascular sonographer at Food Barn . Here I handle many patients . Vascular sonographers, also called vascular ...
Repulrikefiedler789, Animator at 247quickbookshelp
Hello I am a journalist with 5 years of experience crafting timely, informative and factual stories with attention to complexity ...
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 ...
RepMairaSmith, Integration Software Engineer at Absolute Softech Ltd
MairaSmith , an Quality Control Assistant with a record of success in developing and implementing new quality control policies and procedures ...
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 ...
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));
}
}