Re:Nth-to-Last Element in a Singly Linked List
by goodgoblin on Sunday January 31, 2010 @09:04PM
(#1091594)
One I got recently - and blanked on - write a function to generate all the permutations of a string. Recursion preferred.
[ Parent
| on HN ]
Re:Nth-to-Last Element in a Singly Linked List
by bshep on Sunday January 31, 2010 @10:44PM
(#1091726)
Quick and Dirty(probably better ways to do it):
def permute(string, prefix = ''):
if len(string) == 1:
print prefix + string
return
for x in range(0, len(string)):
new_prefix = prefix + string[x]
unused_chars = string[0:x] + string[x+1:]
permute(unused_chars, new_prefix)
Re:Nth-to-Last Element in a Singly Linked List
by dodger1 on Monday February 01, 2010 @02:05AM
(#1091950)
This same website has a solution for the permutation of a string. http://www.mytechinterviews.com/permutations-of-a-string