Re: A question in an interview
From: Balboos (balboos_at_masonicbrother.com.No.Spam)
Date: 05/19/04
- Next message: Sims: "Set the default compression filter."
- Previous message: Mark Robinson: "Re: Sockets in MFC Extension DLL"
- In reply to: Doug Harrison [MVP]: "Re: A question in an interview"
- Next in thread: Rafael: "Re: A question in an interview"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 May 2004 15:54:41 GMT
Actually, maybe what the interviewer is looking for is whether you
handle this redundant characters! Parsing them out of the string, as
the first step, may be all they're looking for: the programmer with
that little extra insight.
The creation of the listing, otherwise, can be (ultimately) worked out
with nested loops incrementing along the string (and a copy of it).
Since one is using 'printing' as a criteria, start at the back a string
(ON the terminating \0), and create combinations by printing the two
substrings as a single output. This takes care of the length changing
as all the combinations grow.
Balboos
Doug Harrison [MVP] wrote:
> Michael Leung wrote:
>
>
>>I was asked to write a function described below with C/C++ in 20 minutes.
>>
>>Implement a function that prints all posible combinations of the characters
>>in a string. These combinations range in length from one to the length of
>>the string. Two combinations that differ only in ordering of their
>>characters are the same combination. In other words,"12" and "31" are
>>different combinations from the input string"123",but 21 is the same as
>>"12".
>>
>>Any good suggestion?
>
>
> Your time has expired, so you can just ignore this problem. :)
>
> Seriously, as Pat Crowe said, a better problem description is called for.
> However, they're probably looking for a solution that assumes all characters
> are unique. Proceeding on that assumption, have you considered viewing the
> positions in the string as analogous to the positions in a binary number?
>
- Next message: Sims: "Set the default compression filter."
- Previous message: Mark Robinson: "Re: Sockets in MFC Extension DLL"
- In reply to: Doug Harrison [MVP]: "Re: A question in an interview"
- Next in thread: Rafael: "Re: A question in an interview"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|