随笔分类 -  算法与数据结构

上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 36 下一页

Leetcode 216. 组合总和 III
摘要:地址 https://leetcode-cn.com/problems/combination-sum-iii/ 解法 DFS 逐个尝试 本代码没加优化 性能一般 阅读全文

posted @ 2019-11-24 20:34 itdef 阅读(187) 评论(0) 推荐(0)

Leetcode 90. 子集 II
摘要:地址 https://leetcode-cn.com/problems/subsets-ii/ 使用DFS 这里取了个巧 使用set做了去重 阅读全文

posted @ 2019-11-24 19:54 itdef 阅读(191) 评论(0) 推荐(0)

Leetcode 83. 删除排序链表中的重复元素
摘要:地址 https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/ 由于是 排序链表 那么只要比较当前和下一个元素的值比较 决定删除与否 同样 还是注意边界问题 code 阅读全文

posted @ 2019-11-24 17:56 itdef 阅读(164) 评论(0) 推荐(0)

Leetcode 19. 删除链表的倒数第N个节点
摘要:地址 https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/ 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 示例: 给定一个链表: 1->2->3->4->5, 和 n = 2. 当删除了倒数第二个节 阅读全文

posted @ 2019-11-24 17:45 itdef 阅读(232) 评论(0) 推荐(0)

LeetCode 1268. 搜索推荐系统 Search Suggestions System
摘要:地址 https://leetcode-cn.com/problems/search-suggestions-system/ 题目描述给你一个产品数组 products 和一个字符串 searchWord ,products 数组中每个产品都是一个字符串。 请你设计一个推荐系统,在依次输入单词 se 阅读全文

posted @ 2019-11-24 15:34 itdef 阅读(515) 评论(0) 推荐(0)

LeetCode 1267 统计参与通信的服务器 Count Servers that Communicate
摘要:地址 https://leetcode-cn.com/problems/count-servers-that-communicate/ 题目描述这里有一幅服务器分布图,服务器的位置标识在 m * n 的整数矩阵网格 grid 中,1 表示单元格上有服务器,0 表示没有。 如果两台服务器位于同一行或者 阅读全文

posted @ 2019-11-24 15:26 itdef 阅读(387) 评论(0) 推荐(0)

LeetCode 1266 访问所有点的最小时间 Minimum Time Visiting All Points
摘要:地址 https://leetcode-cn.com/problems/minimum-time-visiting-all-points/submissions/ 题目描述平面上有 n 个点,点的位置用整数坐标表示 points[i] = [xi, yi]。请你计算访问所有这些点需要的最小时间(以秒 阅读全文

posted @ 2019-11-24 15:11 itdef 阅读(520) 评论(0) 推荐(0)

算法问题实战策略 NTHLON
摘要:地址 https://algospot.com/judge/problem/read/NTHLON 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <queue> 5 6 7 using name 阅读全文

posted @ 2019-11-23 16:41 itdef 阅读(287) 评论(0) 推荐(0)

算法问题实战策略 CHILDRENDAY
摘要:地址 https://algospot.com/judge/problem/read/CHILDRENDAY 题解 ac代码 1 #include <iostream> 2 #include <algorithm> 3 #include <queue> 4 #include <string> 5 # 阅读全文

posted @ 2019-11-21 14:51 itdef 阅读(207) 评论(0) 推荐(0)

LeetCode 1262 可被三整除的最大和 Greatest Sum Divisible by Three
摘要:地址 https://leetcode-cn.com/problems/greatest-sum-divisible-by-three/ 题目描述给你一个整数数组 nums,请你找出并返回能被三整除的元素最大和。 算法1最后数组和 只有三种情况 1 除以3余0 直接返回2 除以3余1 那么要么减少一 阅读全文

posted @ 2019-11-17 13:50 itdef 阅读(596) 评论(0) 推荐(0)

LeetCode 1261 在受污染的二叉树中查找元素 Find Elements in a Contaminated Binary Tree
摘要:地址 https://leetcode-cn.com/contest/weekly-contest-163/problems/find-elements-in-a-contaminated-binary-tree/ 题目描述给出一个满足下述规则的二叉树: root.val == 0如果 treeNo 阅读全文

posted @ 2019-11-17 13:38 itdef 阅读(676) 评论(0) 推荐(0)

acwing 517. 信息传递
摘要:地址 https://www.acwing.com/problem/content/description/519/ 有 n 个同学(编号为 1 到 n)正在玩一个信息传递的游戏。 在游戏里每人都有一个固定的信息传递对象,其中,编号为 i 的同学的信息传递对象是编号为 TiTi 的同学。 游戏开始时 阅读全文

posted @ 2019-11-15 23:07 itdef 阅读(201) 评论(0) 推荐(0)

LeetCode 1255 得分最高的单词集合 Maximum Score Words Formed by Letters
摘要:地址 https://leetcode-cn.com/problems/maximum-score-words-formed-by-letters/ 题目描述你将会得到一份单词表 words,一个字母表 letters (可能会有重复字母),以及每个字母对应的得分情况表 score。 请你帮忙计算玩 阅读全文

posted @ 2019-11-10 22:40 itdef 阅读(365) 评论(0) 推荐(0)

LEETCODE 1254 统计封闭岛屿的数目 Number of Closed Islands
摘要:地址 https://leetcode-cn.com/contest/weekly-contest-162/problems/number-of-closed-islands/ 有一个二维矩阵 grid ,每个位置要么是陆地(记号为 0 )要么是水域(记号为 1 )。 我们从一块陆地出发,每次可以往 阅读全文

posted @ 2019-11-10 14:46 itdef 阅读(273) 评论(0) 推荐(0)

算法问题实战策略 SORTGAME
摘要:地址 https://algospot.com/judge/problem/read/SORTGAME 解答 常规BFS是会超时的 按照书上的提示 应该是打表(居然还有提倡打表的题目) tle 代码 1 #include <iostream> 2 #include <vector> 3 #inclu 阅读全文

posted @ 2019-11-09 23:47 itdef 阅读(276) 评论(0) 推荐(0)

算法问题实战策略 MEETINGROOM 附一份tarjan模板
摘要:地址 https://algospot.com/judge/problem/read/MEETINGROOM 解答 2-sat 代码样例过了 没有ac。 我又没有正确代码对拍。。。。。 已确认是输出问题 修改完成 1 #include <algorithm> 2 #include <iostream 阅读全文

posted @ 2019-11-08 18:26 itdef 阅读(258) 评论(0) 推荐(0)

LeetCode 1248. 统计「优美子数组」
摘要:地址 https://www.acwing.com/solution/leetcode/content/5801/ 题目描述给你一个整数数组 nums 和一个整数 k。 如果某个子数组中恰好有 k 个奇数数字,我们就认为这个子数组是「优美子数组」。 请返回这个数组中「优美子数组」的数目。 算法1暴力 阅读全文

posted @ 2019-11-03 13:51 itdef 阅读(634) 评论(0) 推荐(0)

LeetCode 1245 树的直径
摘要:地址 https://leetcode-cn.com/contest/biweekly-contest-12/problems/tree-diameter/ 给你这棵「无向树」,请你测算并返回它的「直径」:这棵树上最长简单路径的 边数。 我们用一个由所有「边」组成的数组 edges 来表示一棵无向树 阅读全文

posted @ 2019-11-03 12:57 itdef 阅读(956) 评论(0) 推荐(0)

LeetCode 1244. 力扣排行榜
摘要:地址 https://www.acwing.com/solution/LeetCode/content/5765/ 题目描述新一轮的「力扣杯」编程大赛即将启动,为了动态显示参赛者的得分数据,需要设计一个排行榜 Leaderboard。 请你帮忙来设计这个 Leaderboard 类,使得它有如下 3 阅读全文

posted @ 2019-11-03 12:55 itdef 阅读(907) 评论(0) 推荐(0)

LeetCode 1243 数组变换
摘要:地址 https://leetcode-cn.com/contest/biweekly-contest-12/problems/array-transformation/ 首先,给你一个初始数组 arr。然后,每天你都要根据前一天的数组生成一个新的数组。 第 i 天所生成的数组,是由你对第 i-1 阅读全文

posted @ 2019-11-03 12:53 itdef 阅读(353) 评论(0) 推荐(0)

上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 36 下一页

导航