题目如下: Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good if you can obtain a sum of 1 from the array by any possible subset…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 二分查找 日期 题目地址:https://leetcode-cn.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array/ 题目描述 Given an array nums sorted in non-decreasing order, and a number t…
题目如下: You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane. Example 1: Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] Ou…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 循环 日期 题目地址:https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/ 题目描述 We are given that the string "abc" is valid. From any valid string V, we may spli…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 BFS DFS 日期 题目地址:https://leetcode.com/problems/check-completeness-of-a-binary-tree/ 题目描述 Given a binary tree, determine if it is a complete binary tree. Definition of a complete…
题目如下: We are given that the string "abc" is valid. From any valid string V, we may split V into two pieces X and Y such that X + Y (X concatenated with Y) is equal to V.  (X or Y may be empty.)  Then, X + "abc" + Y is also valid. If fo…
题目如下: Given a binary tree, determine if it is a complete binary tree. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as fa…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 方法一:暴力求解 方法二:原地变负做标记 方法三:使用set 日期 [LeetCode] 题目地址:https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ Total Accepted: 14302 Total Submissions: 24993 Difficulty:…
problem 448. Find All Numbers Disappeared in an Array solution: class Solution { public: vector<int> findDisappearedNumbers(vector<int>& nums) { vector<int> res; ; i<nums.size(); i++) { ; nums[tmp] = nums[tmp]> ? -nums[tmp] : n…
[LeetCode]First Missing Positive Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant space. 找到第一个没有出现的正整数 思路:…