Kaede
BAN USERIf input is not sorted,sort it with begin time inc
def unionranges(array):
start = array[0]
end = array[1]
result = []
for i in xrange(2,len(array),2):
if array[i] > end:
result.append((start,end))
start = array[i]
end = array[i+1]
else:
if array[i+1] > end:
end = array[i+1]
result.append((start,end))
return result
hashmap = {'f':['F', '4'], 'b': ['B', '8']}
def printArray(str,result):
if str == "":
print ''.join(result)
else:
result.append(str[0])
printArray(str[1:],result);
result.pop()
c = hashmap.get(str[0])
if c != None:
for r in c:
result.append(r)
printArray(str[1:],result);
result.pop()
printArray("fab",[])
use XOR
- Kaede March 19, 2013