每日一题
文章平均质量分 73
每日一道算法题,每天分享一道算法题的解题思路及实现代码以及我从中获得的知识和思想
꧃小王同学ꦺ
这个作者很懒,什么都没留下…
展开
-
数组异或操作
XOR Operation in an ArrayGiven an integer n and an integer start.Define an aray nums where nums[i] = start + 2*i (0-indexed) and n == nums.length.Return the bitwise XOR of all elements of nums.Example 1:Input: n = 5, start = 0Output: 8Explanation:原创 2021-05-07 16:57:12 · 659 阅读 · 0 评论 -
平方数之和
Sum of Square NumbersGiven a non-negative integer c, decide whether there’s two integers a and b such that a^2 + b^2 = c.Example 1:Input: c = 5Output: trueExplanation: 1 * 1 + 2 * 2 = 5Example 2:Input: c = 3Output: falseExample 3:Input: c =原创 2021-04-28 15:37:44 · 478 阅读 · 0 评论 -
组合总数IV
Combination Sum IVGiven an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target.The answer is guaranteed to fit in a 32-bit integer.Example 1:Input: nums = [1, 2, 3], target = 4原创 2021-04-24 11:32:59 · 136 阅读 · 0 评论 -
解码方法
Decode WaysA message containing letters from A-Z can be encoded into numbers using the following mapping: ‘A’ -> “1” ‘B’ -> “2” … ‘Z’ -> “26”To decode the encoded message, all the digits must be grouped then mapped back into letters usin原创 2021-04-21 19:59:13 · 3955 阅读 · 2 评论 -
实现strStr()
implement strStr()Implement strStr()Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Clarification:What should we return when needle is an empty string? This is a great question to ask during an in原创 2021-04-20 11:52:19 · 92 阅读 · 0 评论 -
移除元素
Remove ElementGiven an array nums and a value val,remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.The orde原创 2021-04-19 21:55:00 · 163 阅读 · 0 评论 -
删除有序数组中的重复项
Remove Duplicates from Sorted ArrayGiven a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.Do not allocate extra space for another array, you must do this by modifying the input array原创 2021-04-18 13:51:00 · 136 阅读 · 0 评论 -
二叉搜索树节点最小距离
Minimum Distance Between BST NodesGiven the root of a Binary Search Tree(BST), return the minimum difference between the values of any two different nodes in the tree.今天的题目是求二叉搜索树的节点之间的最小距离,即求树中任意两个节点差值的最小值。而我们知道,二叉搜索树的特点是,左子树一定小于根节点,右子树一定大于根节点,而且二叉搜索树原创 2021-04-13 21:01:55 · 237 阅读 · 0 评论 -
最大数
Largest NumberGiven a list of non-negative integers nums ,arrange them such that thry form the largest number.Note: The result may be very large, so you need to return a string instead of an integer.今天的题目依然是一道中等难度的题,题目要求一个非负整数数组能拼接出的最大数。即输入一个非负整数数组,返回这原创 2021-04-12 19:08:08 · 127 阅读 · 0 评论 -
搜索旋转排序数组II
Search in Rotated Sorted Array II There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values). Before being passed to your function, nums is rotated at an unknown pivot index k(0<=k<nums.length) such that原创 2021-04-07 14:41:03 · 160 阅读 · 0 评论 -
删除有序数组中的重复项II
Remove Duplicates from Sorted Array II Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra space for another array; you must do this by modifying the inp原创 2021-04-06 19:52:22 · 258 阅读 · 0 评论 -
笨阶乘
Clumsy Factorial Normally, the factorial of a positive integer n is the product of all positive integers less than or equal to n. For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 . We instead make a clumsy factorial: using the intege原创 2021-04-01 08:45:18 · 126 阅读 · 0 评论 -
子集II
Subsets II Given an integer array nums that may contain duplicates, return all possible subsets(the power set). The solution set must not contain duplicate subsets. Return the solution in an order. 题目的输入是一个数组,其中可能含有重复的元素;要求的结果是这个数组的所有子集的集合,也就是幂集,且结果集原创 2021-03-31 16:01:51 · 70 阅读 · 0 评论 -
搜索二维矩阵
Search a 2D Matrix今天的每日一题是一道中等难度,题目描述如下:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row if greater tha原创 2021-03-30 12:56:55 · 141 阅读 · 0 评论 -
删除有序链表中的重复节点II
Remove Duplicates from sorted list II #算法每日一题#今天的每日一题,它的题目描述是这样的:Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well.解法一原创 2021-03-25 16:03:47 · 345 阅读 · 0 评论