LeetCode之“数学”:Plus One】的更多相关文章

[2]Add Two Numbers (2018年12月23日,review) 链表的高精度加法. 题解:链表专题:https://www.cnblogs.com/zhangwanying/p/9797184.html [7]Reverse Integer (2018年12月23日, review) 给了一个32位的整数,返回它的reverse后的整数.如果reverse后的数超过了整数的范围,就返回 0. Example 1: Input: 123 Output: 321 Example 2:…
题目链接 题目要求: Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 这道题不难,不过可能会误解是二进制数的相加,切记!程序如下: class Solution { public: vector<in…
题目链接 题目要求: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the proces…
1. Reverse Integer 题目链接 题目要求: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if…
题目链接 题目要求: Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Assume that the total area is never beyond the maximum possible value…
乘方 思路是:pow(x,n) = pow(x,n/2)*pow(x,n-n/2) 递归实现 public double myPow(double x, int n) { if (n==0) return 1.0; else if (n>0) { double half = (double) myPow(x,n/2); if (n%2==0) return half*half; else return half*half*x; } else { if (n==Integer.MIN_VALUE)…
一.数据结构相关 链表 1. 相交链表 2. 反转链表 3. 合并两个有序链表 4. 删除排序链表中的重复元素 5. 删除链表的倒数第 n 个节点 6. 两两交换链表中的节点 7. 两数相加 II 8. 回文链表 9. 分隔链表 10.奇偶链表 数组与矩阵 1. 移动零 2. 重塑矩阵 3. 最大连续1的个数 4. 搜索二维矩阵 II 5. 有序矩阵中第 K 小的元素 6. 错误的集合 7. 寻找重复数 8. 优美的排列 II 9. 数组的度 10. 托普利茨矩阵 11. 数组嵌套 12. 最多…
LeetCode初级算法的Python实现--排序和搜索.设计问题.数学及其他 1.排序和搜索 class Solution(object): # 合并两个有序数组 def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify…
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example, given n = 2, return 1 (2 = 1 + 1); given n = 10, return 36 (10 = 3 +…
数学篇 # 题名 刷题 通过率 难度 2 两数相加   29.0% 中等 7 反转整数 C#LeetCode刷题之#7-反转整数(Reverse Integer) 28.6% 简单 8 字符串转整数 (atoi)   15.3% 中等 9 回文数 C#LeetCode刷题之#9-回文数(Palindrome Number) 51.7% 简单 12 整数转罗马数字   53.8% 中等 13 罗马数字转整数 C#LeetCode刷题之#13-罗马数字转整数(Roman to Integer) 53…