saikrishna chunchu
BAN USER
- 4of 4 votes
AnswersGiven two strings, find that the if the letters in both the strings are same? i.e. can we be able to make string2 out of string1 by shuffling the words and vice versa.
- saikrishna chunchu in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm
Can you elaborate the question?
- saikrishna chunchu April 17, 2012Exmples:
String1 - dad, String2 - add
String1 - mad, String2 - dam
String1 - cat, String2 - act
In the above, shuffling the characters in String1 makes String2.
Complexity of the solution:
Lets take that, no collision in the Hashmap, in order to insert or search the data, complexity is O(1) - may not be the case always.
In order to insert a String into the Hasmap, Complexity is O(n)
In order to compare the second String with hasmap, Complexity is O(n).
Hence, total complexity is O(n)+O(n) ==> O(2n). We have not considered the complexity of the hasmap yet.
Space overhead is O(n).
Can we have a better solution??
How about the worst case complexity?
If i take, quick sort for sorting the strings, then O(n2) would be the complexity for each string.
With this solution, to sort two strings it can reach to O(n2) + O(n2).
Can we have better solution?
RepI am Jenae Wilder and I work as a content writer, A writer at day, and a reader at night ...
Repnickjonson885, Consultant at ASU
I am Department director in a Libera company. I live in Buffalo NY, USA. I am a hard worker girl ...
Repaileenpankney, photographer at Precious Moments
Confident and dedicated photographer with experience in both professional and freelance photography. I like to explore Black Magic Spell To ...
Repsalinagray, Development Support Engineer at Atmel
Hi I am Salina Gray,I live in Texas and work as a Design Team Member. I am new to ...
RepEllaFlores, Associate at Alcatel Lucent
Ella , a Tour bus driver in Sounds Great company Inc. A charter bus driver is responsible for providing comfortable and ...
Repsamuelcsmith700, Accountant at Absolute Softech Ltd
Je suis chef d'équipe de support Office dans une entreprise Action Auto. Je suis également rédacteur de blog. J ...
Repsusancmeans, Apple Phone Number available 24/7 for our Customers at Absolute Softech Ltd
I am Susan from Bronx, I am working as a Business management analyst in Brendle's company. I Have a ...
Repvickiwgerber, Member Technical Staff at Boomerang Commerce
I am Vicki From San Antonio USA, I am working as an Interior decorator in Golden Joy company. I have ...
Repsharoneruther, AT&T Customer service email at ABC TECH SUPPORT
I am Sharon, from Bethlehem USA. I am working as a Park naturalist in Sammy's Record Shack company. I ...
Repkellydbrown23, Jr. Software Engineer at Auto NInja
I live in College Park USA with my family, and my current job is clerk in Luria’s company. I ...
Repharoldjmaloney, Accountant at ASU
Hi, I am a Computer systems administrator from texas. Experienced in running a wide variety of software development Company. Looking ...
Repharryhamesh, Android Engineer at ADP
I placement officers usually work in colleges and universities. One of My friends taught me about prayers that break curses ...
Repbrakpeter2, AT&T Customer service email at Absolute Softech Ltd
My Profession Is photography for a number of years.My Friends were interested in photography, so I was always exposed ...
Repnorahuerta1111, Accountant at ABC TECH SUPPORT
Hey, I'm Nora Huerta, and I'm working as a journalist. And nowadays I am doing part time jobs ...
RepIndianastrologyguru, Data Scientist at ABC TECH SUPPORT
Hey I'm Shelly Renee and I'm working as a system developer. Currently working part time on a project ...
Repcherylbgrant, Python Experienced at Bankbazaar
Je suis Cheryl, une traductrice multilingue passionnée avec 3 ans d'expérience dans la traduction de différentes langues telles que ...
RepRileyAllen, Analyst at British Telecom
I enjoy spending my spare time outside and engaging in activities such as hiking, swimming, biking, and jogging. Explore new ...
Reptaylamowll, Analyst at AMD
Aspire to work in a challenging environment, where my exceptional skills and abilities are completely explored, and I can easily ...
RepLizaZeiger, Animator at Accenture
I am a Loan processing clerk. My work is assembling, administering and processing your loan application paperwork before it gets ...
Rephelenweiver, Consultant at ASU
I am Helen , policy analyst at Sunflower Market , with 3 years of experience building and maintaining relationships with elected officials ...
Replimlocica, News reporter at Smitty's Marketplace
Hello, I am a News reporter. Master's Degree in astrology and News reporter and 10 years of experience working ...
RepGiannaDavid, Author at The times
I am an Author, I have a passion for reading and creative writing and attend many workshops and conventions surrounding ...
Repgarycsroka, Backend Developer at Axiom Sources
Hi I’m Gary, an average 19 year old in a state college who sees life as an adventure.Provide ...
Repteresawells858, Java Developer at 247quickbookshelp
I am Teresa. I work as a Software engineer at Asian Fusion Company. I was born in the US and ...
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 ...
- saikrishna chunchu April 18, 2012