Re: A question in an interview

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Balboos (balboos_at_masonicbrother.com.No.Spam)
Date: 05/19/04


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?
>



Relevant Pages

  • Re: How to convert Infix notation to postfix notation
    ... If this is for an error message, why isn't it using stderr for its output? ... array of 15 characters, and you call this function with the limit 15 on ... Making sure that the only string I allocate and append to, ... because mulFactor in all versions must needs incorporate the functions ...
    (comp.lang.c)
  • Re: Prothon should not borrow Python strings!
    ... """It does not make sense to have a string without knowing what encoding ... same cul de sac as Python. ... Prothon_String_As_ASCII // raises error if there are high characters ... Python's split between byte strings and Unicode strings is ...
    (comp.lang.python)
  • Re: printing variable problems
    ... Marco van de Voort said ... printing a string that is prefixed with a given number of space ... characters, does not always start at the same position? ...
    (comp.lang.pascal.borland)
  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... put them in stupid places. ... Programming is difficult (as you must surely appreciate, ... > strings will be in the range 1...1000 characters. ... impose an artificially small limit on string length." ...
    (comp.programming)
  • Re: Byte Array to String
    ... retrieved text will mismatch the original characters. ... encoding the characters. ... Dim strFileData as String ...
    (microsoft.public.dotnet.framework.aspnet)