随笔分类 -  思维

脑力不够,题数来凑
摘要:传送门 给你一个二进制字符串 s ,现需要将其转化为一个 交替字符串 。请你计算并返回转化所需的 最小 字符交换次数,如果无法完成转化,返回 -1 。 交替字符串 是指:相邻字符之间不存在相等情况的字符串。例如,字符串 "010" 和 "1010" 属于交替字符串,但 "0100" 不是。 任意两个 阅读全文
posted @ 2021-05-24 09:25 cono奇犽哒 阅读(364) 评论(0) 推荐(0)
摘要:传送门 题目描述: 监狱有 n 个房间,每个房间关押一个犯人,有 m 种宗教,每个犯人会信仰其中一种。如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱。 答案对 100,003 取模。 思路:如果直接算有多少种可能的状态发生越狱就很麻烦,可能的情况有,两个相邻的位置宗教相同, 阅读全文
posted @ 2021-05-05 11:05 cono奇犽哒 阅读(63) 评论(0) 推荐(0)
摘要:题目描述: 1128 N Queens Puzzle (20 分) The "eight queens puzzle" is the problem of placing eight chess queens on an 8 chessboard so that no two queens thre 阅读全文
posted @ 2021-03-12 15:59 cono奇犽哒 阅读(91) 评论(0) 推荐(0)
摘要:题目描述: 1038 Recover the Smallest Number (30 分) Given a collection of number segments, you are supposed to recover the smallest number from them. For ex 阅读全文
posted @ 2021-03-11 21:34 cono奇犽哒 阅读(75) 评论(0) 推荐(0)