ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories >> Code-Snippets >> Programming-Code >> C-Code
 
 
 
Question
Write a prog to accept a given string in any order and flash
error if any of the character is different. 

For example : If abc is the input then abc, bca, cba, cab
bac are acceptable, but aac or bcd are unacceptable.
 Question Submitted By :: Coder_1
I also faced this Question!!     Rank Answer Posted By  
 
Answer
My answer is O(n) - but it is done in C# sorry for C guys
        public bool isAccepted(string original, string
toCompare)
        {
            if (original.Length != toCompare.Length)
                return false;
            bool[] flags = new bool[128];
            for (int i = 0; i < toCompare.Length; i++)
                flags[toCompare[i]] = true;
            for (int i = 0; i < original.Length; i++)
                if (!flags[original[i]])
                    return false;
            return true;
        }
 
0
Yegullelew
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com