JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat  | Threaded  | Tree
Previous Thread  |  Next Thread
Foiled by a Div2-250! | Reply
I got asked in interview:
"Write a C function that accepts a sorted lowercase string, and returns a string containing in sorted order one of each character present in the input".
void Func(char *str, int length);

I got flustered (unusual at interview for me) and produced something like this:
void Func(char *str,int length)
{
 bool present[26]={false};
 for(int i=0;i<length;++i)
 {
  present[str[i]-'a']=true;
 }
 for(int i=0,p=0;i<26;++i)
 {
  if(present[i])
   str[p++]=(char)(i+'a');
 }
 str[p]='\0';
}

Pretty special, eh?
Subject Author Date
Foiled by a Div2-250! d000hg Oct 27, 2006 at 6:27 AM EDT
Re: Foiled by a Div2-250! Stroker_Ace Oct 27, 2006 at 8:29 AM EDT
Re: Foiled by a Div2-250! dcp Oct 27, 2006 at 10:01 AM EDT
Re: Foiled by a Div2-250! aussie Oct 27, 2006 at 10:07 AM EDT
Re: Foiled by a Div2-250! Stroker_Ace Oct 27, 2006 at 10:15 AM EDT
Re: Foiled by a Div2-250! aussie Oct 27, 2006 at 10:57 AM EDT
Re: Foiled by a Div2-250! slex Oct 27, 2006 at 11:05 AM EDT
Re: Foiled by a Div2-250! Stroker_Ace Oct 27, 2006 at 11:14 AM EDT
Re: Foiled by a Div2-250! aussie Oct 27, 2006 at 11:21 AM EDT
Re: Foiled by a Div2-250! slex Oct 27, 2006 at 11:27 AM EDT
Re: Foiled by a Div2-250! Stroker_Ace Oct 27, 2006 at 11:34 AM EDT
Re: Foiled by a Div2-250! Uranium-235 Oct 31, 2006 at 12:58 PM EST
Re: Foiled by a Div2-250! rserranop Oct 28, 2006 at 6:56 PM EDT
Re: Foiled by a Div2-250! rserranop Oct 28, 2006 at 7:18 PM EDT
Re: Foiled by a Div2-250! dcp Oct 27, 2006 at 10:26 AM EDT
Re: Foiled by a Div2-250! Stroker_Ace Oct 27, 2006 at 10:12 AM EDT
Re: Foiled by a Div2-250! dcp Oct 27, 2006 at 10:29 AM EDT
Re: Foiled by a Div2-250! d000hg Oct 28, 2006 at 6:37 PM EDT
Re: Foiled by a Div2-250! TAG Nov 1, 2006 at 2:57 PM EST
Re: Foiled by a Div2-250! Malkava Jan 14, 2007 at 12:55 AM EST
Re: Foiled by a Div2-250! Stroker_Ace Oct 27, 2006 at 10:44 AM EDT
Re: Foiled by a Div2-250! slex Oct 27, 2006 at 11:02 AM EDT
Re: Foiled by a Div2-250! aussie Oct 27, 2006 at 11:04 AM EDT
Meh? jmzero Nov 1, 2006 at 12:37 PM EST
Re: Meh? NeverMore Nov 1, 2006 at 1:54 PM EST
Re: Meh? Insight Nov 1, 2006 at 2:32 PM EST
Re: Meh? jmzero Nov 1, 2006 at 2:52 PM EST
Re: Meh? TAG Nov 1, 2006 at 3:38 PM EST
Re: Meh? jmzero Nov 1, 2006 at 4:42 PM EST
Re: Meh? TAG Nov 1, 2006 at 4:54 PM EST
Re: Meh? Stroker_Ace Nov 2, 2006 at 3:57 AM EST
Re: Meh? rgrig Nov 2, 2006 at 6:26 AM EST
Re: Meh? aussie Nov 2, 2006 at 6:38 AM EST
Re: Meh? jmzero Nov 2, 2006 at 10:52 AM EST
Re: Meh? Kawigi Nov 2, 2006 at 12:21 PM EST
Re: Meh? jmzero Nov 2, 2006 at 12:58 PM EST
Re: Meh? Kawigi Nov 2, 2006 at 1:10 PM EST
Re: Meh? dskloet Nov 2, 2006 at 2:26 PM EST
Re: Meh? Kawigi Nov 2, 2006 at 3:17 PM EST
Re: Meh? rgrig Nov 3, 2006 at 3:43 AM EST
Re: Meh? Krzysan Nov 4, 2006 at 1:23 AM EST
Re: Meh? sjelkjd Nov 4, 2006 at 12:32 AM EST
Re: Meh? tster123 Nov 4, 2006 at 1:29 AM EST
Re: Meh? TAG Nov 4, 2006 at 2:10 AM EST
Re: Meh? Kawigi Nov 4, 2006 at 12:02 PM EST
Re: Meh? rgrig Nov 5, 2006 at 6:17 AM EST
Re: Meh? tster123 Nov 5, 2006 at 12:28 PM EST
Re: Meh? rgrig Nov 5, 2006 at 1:08 PM EST
Re: Meh? tster123 Nov 5, 2006 at 2:42 PM EST
Re: Foiled by a Div2-250! dimkadimon Nov 4, 2006 at 6:14 PM EST
Re: Foiled by a Div2-250! TAG Nov 4, 2006 at 11:18 PM EST
Re: Foiled by a Div2-250! aussie Nov 5, 2006 at 12:25 AM EST
Re: Foiled by a Div2-250! Kawigi Nov 5, 2006 at 4:15 AM EST
Re: Foiled by a Div2-250! tster123 Nov 5, 2006 at 1:17 AM EST
Re: Foiled by a Div2-250! dimkadimon Nov 5, 2006 at 7:18 PM EST
Re: Foiled by a Div2-250! aussie Nov 5, 2006 at 7:31 PM EST
Re: Foiled by a Div2-250! dimkadimon Nov 5, 2006 at 7:34 PM EST
Re: Foiled by a Div2-250! tster123 Nov 5, 2006 at 11:09 PM EST
Re: Foiled by a Div2-250! slex Nov 6, 2006 at 6:24 AM EST
Re: Foiled by a Div2-250! tster123 Nov 6, 2006 at 6:44 AM EST
Re: Foiled by a Div2-250! slex Nov 6, 2006 at 6:58 AM EST
Re: Foiled by a Div2-250! aussie Nov 6, 2006 at 7:25 AM EST
Re: Foiled by a Div2-250! Pops Nov 6, 2006 at 9:04 AM EST
Re: Foiled by a Div2-250! Kawigi Nov 6, 2006 at 12:03 PM EST
Re: Foiled by a Div2-250! slex Nov 6, 2006 at 12:30 PM EST
Re: Foiled by a Div2-250! dskloet Nov 6, 2006 at 2:58 AM EST
Re: Foiled by a Div2-250! d000hg Nov 8, 2006 at 4:19 AM EST
Re: Foiled by a Div2-250! slex Nov 8, 2006 at 7:17 AM EST
Re: Foiled by a Div2-250! Kawigi Nov 8, 2006 at 1:02 PM EST
Re: Foiled by a Div2-250! rgrig Nov 8, 2006 at 1:42 PM EST
RSS