编程基础

#并查集
def find(index):
    if parent[index]!=index:
        parent[index] = find(parent[index])
    return parent[index]

def uion(index1,index2):
    parent[find(index1)] = find(index2)
    
所有可能的排列
s = "1234"
ret = []
s = list(s)
def perm(pos,s):
    if pos+1 == len(s):
        ret.append(''.join(s))
        return
    for i in range(pos,len(s)):
        s[i],s[pos]=s[pos],s[i]
        perm(pos+1,s)
        s[i],s[pos]=s[pos],s[i]
perm(0,s)
ret
#素数筛/埃氏筛
import math
INT_MAX = 1000
dp = [True]*(INT_MAX+1)
for i in range(2,math.ceil(math.sqrt(INT_MAX))):
    k = i
    while i*k<=INT_MAX:
        dp[i*k]=False
        k = k+1
for ind,num in enumerate(dp):
    if num == True:
        print(ind)
合并链表;
反转链表


全部评论
学习新的知识
点赞 回复 分享
发布于 2022-10-20 14:42 河南

相关推荐

11-03 18:50
门头沟学院 Java
迷茫的大四🐶:问就是马上到,一周五天,6个月以上,全国可飞
点赞 评论 收藏
分享
king327:要从现有项目中挖掘1-2个你解决过的具体技术难题 详细描述你的解决方案、技术选型理由和最终效果 这比罗列更多基础功能更有说服力
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务