作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 遍历 最大公约数 日期 题目地址: https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/description/ 题目描述 In a deck of cards, each card has an integer written on it. Return true if and…
In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where: Each group has exactly X cards. All the cards in eac…
原题 题目原意可转换为 两组有大于等于2的公因数 /** * @param {number[]} deck * @return {boolean} */ var hasGroupsSizeX = function(deck) { var map = {}; for (let i = 0; i < deck.length; i++) { if (map[deck[i]]) map[deck[i]] += 1; else map[deck[i]] = 1; } var min = map[deck[…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 约瑟夫环 日期 题目地址:https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/ 题目描述 0,1,,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字.求出这个圆圈里剩下的最后一个数字. 例如,0.1.2.3.4这5个…
problem 914. X of a Kind in a Deck of Cards 题意:每个数字对应的数目可以均分为多组含有K个相同数目该数字的数组. 思路:使用 map 结构记录数组中每个元素出现的次数,该题转化为求次数的最大公约数,若所有次数的最大公约数大于或者等于 2,返回 true,否则返回 false. solution: class Solution { public: bool hasGroupsSizeX(vector<int>& deck) { //Greate…
[LeetCode]106. Construct Binary Tree from Inorder and Postorder Traversal 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/description/ 题目描述: Given inorder and postorder traversal…
[LeetCode]117. Populating Next Right Pointers in Each Node II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/description/ 题目描述: Follow up for problem "Populating Next Right Pointers in Each…
In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where: Each group has exactly X cards. All the cards in eac…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典统计 日期 题目地址:https://leetcode-cn.com/problems/index-pairs-of-a-string/submissions/ 题目描述 You are given an array of strings words and a string chars. A string is good if it can be…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 preSum + 字典 日期 题目地址:https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/ 题目描述 Given the head of a linked list, we repeatedly delete consecutive sequ…