![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode成长
文章平均质量分 80
LilyNothing
不会写文章的程序员不是好的摄影师
展开
-
算法题——任意进制转换
求任意两个不同进制非负整数的转换(2进制~16进制)原创 2022-03-13 22:33:17 · 1839 阅读 · 0 评论 -
数组的循环移动
数组的循环移动是考查的算法中比较常见的,有循环左移,循环右移之类的。当然,不会直接就考查移动的算法,还会有一定的时间复杂度,空间复杂度的要求之类的,这才是算法要求的,所以这两天刚好看到类似的题目,就记录一下。题目要求如有数组abcd1234,让数组向右边移动两位,变成了34abcd12。这就是数组的循环右移操作,那么要求在尽可能少的时间复杂度下实现将整个数组移动m次的这个操作。不考虑时间复杂度的实现原创 2017-03-21 18:08:08 · 3670 阅读 · 0 评论 -
删除线性表中的重复元素
小记:烦躁ing,看不进去其它东西,就来刷刷leetcode的题目,今天刷到一道比较基础的删除已排序数组的题目,感觉很典型,就记录了一下。一、leetcode原题:删除已排序数组重复元素先给出leetcode原题照片:原题大意就是对于一个已经排好序的数组,删除重复元素。要求空间复杂度为O(1)。也就是不能重新申请新的数组。解题思路:对于已经排好序的数组,那么重复元素必然是聚原创 2017-02-27 17:32:05 · 11620 阅读 · 0 评论 -
leetcode--Palindrome Number
详情见:http://blog.csdn.net/sinat_27683281/article/details/50563221转载 2016-01-23 20:30:11 · 392 阅读 · 0 评论 -
leetcode--Unique Paths && Unique Paths ii
见:http://blog.csdn.net/sinat_27683281/article/details/50557912转载 2016-01-23 20:26:15 · 306 阅读 · 0 评论 -
leetcode--Pow(x,n)
题目要求:就是求x的n次幂。Notice:要注意x和n的特殊取值1)n==0的时候,均返回1;2)x == 1或者x==0时返回 x3)n可能会等于int的表示范围的最小值INT_MIN,此时要返回1求解该题的方法有几种,详细参考:http://blog.unieagle.net/2012/08/23/leetcode%E9%A2%98%E7%9B%AE%E转载 2016-01-23 20:08:54 · 484 阅读 · 0 评论 -
leetcode--Reverse integer
题目要求:将一个整数转为逆序。如123转为321,-123转为-321.解题思路:对于负数,可以转为正数来进行。对于正数,可以采用result = result*10 + (x/10)%10的公式进行转换。一个数对10取余可以取得最后一位数,对10 取商,可以得到除尾数以外的其它所有数。Notice:1)int型的最大数值和最小数值分别为INT_MAX = 21474836转载 2016-01-23 20:17:06 · 461 阅读 · 0 评论 -
leetcode--Plus one
转自我的另外一个账号啦!题目要求: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.转载 2016-01-23 20:19:00 · 430 阅读 · 0 评论 -
leetcode--Pascal's Triangle && ii
题目要求:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]就是用代码实现杨辉三角形。原创 2016-01-23 20:04:15 · 433 阅读 · 0 评论 -
leetcode--search in rotated sorted arry
题目要求:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array原创 2016-01-23 20:01:54 · 487 阅读 · 0 评论 -
leetcode--Sqrt(x)
题目:https://leetcode.com/problems/sqrtx/ 也就是求X的平方根啦!有两种方法求解:1)直接通过X的平方根小于X/2 +1这个条件进行判断,进行二分搜索。源代码如下:class Solution {public: int mySqrt(int x) { if(x == 0) return 0原创 2016-01-23 19:58:17 · 417 阅读 · 0 评论 -
leetcode--Search a 2D Matrix
题目要求:https://leetcode.com/problems/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原创 2016-01-23 19:54:25 · 352 阅读 · 0 评论 -
leetcode---Valid Parentheses
题目要求:https://leetcode.com/problems/valid-parentheses/ Given a string containing just the characters '(', ')','{', '}', '[' and ']', determine if the input string is valid.The brackets must close原创 2016-01-23 19:49:07 · 520 阅读 · 0 评论 -
leetcode--Evaluate Reverse Polish Notation
题目:https://leetcode.com/problems/evaluate-reverse-polish-notation/其实中文意思就是根据后缀表达式来求表达式结果!!解题思路:就是利用栈来实现啦!遇到数字入栈,遇到运算符出栈两个数进行运算!源代码如下:class Solution {public: int evalRPN(vector& tokens) {原创 2016-01-23 19:42:55 · 414 阅读 · 0 评论 -
leetcode--字符串转为整型
今天在leetcode上面做到的第二个题是:https://leetcode.com/problems/string-to-integer-atoi/是关于字符串转为整数的类型。题目分析:该问题的内容很长,其实主要是描述一些可能的边界问题。对于整数来说,两大问题就是是正负号的问题和是整数范围是否越界的问题。思路比较简单,就是先去掉多余的空格字符,然后读符号(注意原创 2016-01-23 19:36:53 · 550 阅读 · 0 评论