# 拼多多面试跪经

import itertools
import sys

def solution(N,nums):
candidates=itertools.combinations(nums,2)
tmp=[]
for item in candidates:
tmp.append(sum(item))
tmp.sort()
minimal=sys.maxint
for i in range(1,len(tmp)):
minimal=min(minimal,tmp[i]-tmp[i-1])
return minimal

try:
while True:
fisrtLine = line.split(" ")
N=int(fisrtLine[0])
SecondLine = line.split(" ")
nums=[]
for i in SecondLine:
nums.append(int(i))

print(solution(N,nums))
if line == '':
break
except:
pass


import collections
import heapq
import sys
def solution(times,A,B):
hp=[]
for i,time in enumerate(times):
if time!=0:
heapq.heappush(hp,(i,time))
numA=""
numB=""
i=0
while hp:
val,time=heapq.heappop(hp)
if i%2==0 and len(numA)<A:
numA+=str(val)
time -= 1
elif i%2==1 and len(numB)<B:
numB+=str(val)
time -= 1
if len(numA)==A and len(numB)==B:
return int(numA)*int(numB)
i+=1
if time>0:
heapq.heappush(hp,(val,time))

try:
while True:
fisrtLine = line.split(" ")
times=[]
for i in fisrtLine:
times.append(int(i))
A=int(line)
B = int(line)

print(solution(times,A,B))
if line == '':
break
except:
pass


import itertools

def solution(myinput,d):
candidates=itertools.combinations(myinput,2)
print(candidates)
count=0
length=0
for can in candidates:
length+=1
if abs(can[0]-can[1])<=d:
count+=1
return float(count)/float(length)

try:
while True:
print(solution([31,18,19,1,25],10))

# print(solution(word1,word2))
if input() == '':
break
except:
print(1)
pass


四.Edit Distance

n=2 : 华为， 为手， 手机。 先加上限制条件对于字母、数字，不做分词。如：华为手机P30新款，输出：华，为，手，机，P30，新，款

# coding=utf-8
class solution(object):
def isNumOrAb(self,cn):
return '0' <= cn <= '9' or 'a' <= cn <= 'z' or 'A' <= cn <= 'Z'

def sliding_windows(self, string, n):
if len(string) == 0:
return string
res = []
l=r=0
while r<=len(string):
while r<len(string) and r-l<n and not (self.isNumOrAb(string[r])):
r+=1
cur=string[l:r]
res.append(cur)
if r<len(string) and self.isNumOrAb(string[r]):
l=r
while r<len(string) and self.isNumOrAb(string[r]):
r+=1
cur = string[l:r]
res.append(cur)
l=r
continue
l+=1
r+=1

return res

if __name__ == "__main__":
print (solution().sliding_windows("华为手机P30新款", 5))

1.假如你有一个size是10000000的map，里面可能放的是session,怎么快速的查到其中的key,value？

2.什么是协程

3.redis原子操作

4.JAVA原子性

5.如何实现redis锁

5.如何实现redis缓存

6.项目里用了LSH算法？介绍一下