![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
yangb25
这个作者很懒,什么都没留下…
展开
-
LeetCode 7. Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Note: The input is assumed to be a 32-bit signed integer. Your function s原创 2017-06-28 17:13:58 · 123 阅读 · 0 评论 -
LeetCode 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. 检查一个整数是否回文 根据回文数的特点 ,逆向相同,取收尾比较 考虑奇数位与偶数位回文的区别,注意处理特殊情况 class Solution { public: bool isPalindrome(int x) {原创 2017-06-28 18:09:48 · 131 阅读 · 0 评论 -
LeetCode 15.3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain原创 2017-06-28 19:14:54 · 162 阅读 · 0 评论 -
LeetCode 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree and sum原创 2017-06-28 19:31:26 · 147 阅读 · 0 评论 -
LeetCode 50. Pow(x, n)
Implement pow(x, n). 根据n的取值分三种情况,n>0、n==0和n 前几次提交结果为Time Limit Exceeded,改进最后ac版本如下: 分治思想: x^n = x^(n/2) * x^(n/2) * x^(n%2),将x的n次方降幂为n/2,讨论n的奇偶性,如果n为奇数,则多乘一个v。 class Solution { public:原创 2017-06-28 21:07:31 · 135 阅读 · 0 评论 -
LeetCode 18. 4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution原创 2017-07-05 20:01:04 · 157 阅读 · 0 评论 -
LeetCode 62. Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the原创 2017-07-06 13:08:45 · 154 阅读 · 0 评论 -
LeetCode 547. Friend Circles
There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, the原创 2017-07-06 13:29:44 · 324 阅读 · 0 评论