自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 收藏
  • 关注

原创 《leetCode-php》判断链表是否有环

Given a linked list, determine if it has a cycle in it. 判断一个链表是否有环 Follow up: Can you solve it without using extra space? <?php class ListNode { public $next = null; public $val; publ...

2018-12-28 20:11:17 941

原创 《leetCode-php》链表中环的入口

Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you solve it without using extra space? 不使用额外空间判断一个链表是否有环,虽然说的是不使用额外空间,但是还是需要一个变量来实现快慢指针 ...

2018-12-27 14:17:57 213

原创 《leetCode-php》重排序链表

Given a singly linked list L: L 0→L 1→…→L n-1→L n, reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→… You must do this in-place without altering the nodes' values. 更改链表的顺序 For example, Given{1,2,3,4}, r...

2018-12-21 20:48:15 129

原创 《leetCode-php》二叉树前序遍历

Given a binary tree, return the preorder traversal of its nodes' values. 二叉树前序遍历(中左右) For example: Given binary tree{1,#,2,3},    1     \      2     /    3 return[1,2,3]. Note: Recursive solution i...

2018-12-21 16:40:18 263

原创 《leetCode-php》二叉树的后序遍历

Given a binary tree, return the postorder traversal of its nodes' values. 给定一个二叉树,返回其节点值的后序遍历(左右中的顺序) For example: Given binary tree{1,#,2,3},    1     \      2     /    3 return[3,2,1]. Note: Recu...

2018-12-20 22:54:38 147

原创 《leetCode-php》插入法排序链表

Sort a linked list using insertion sort. 插入法排序链表 <?php class ListNode { public $next = null; public $val; public function __construct($val) { $this->val = $val; } } ...

2018-12-20 16:59:28 125

原创 《leetCode-php》对链表排序

Sort a linked list in O(n log n) time using constant space complexity. 使用o(nlogn)的时间复杂度和常量空间复杂度,对链表排序。 可以使用归并排序,符合时间复杂度和空间复杂度 <?php class ListNode { public $next = null; public $val; ...

2018-12-20 14:37:09 345

原创 linux小知识

今天同事遇到了一个问题,整理一下。 在/var/spool/postfix/maildrop中出现了很多数据文件,占用大量存储。 一番搜索之后,发现是crontab的输出会以邮件的形式发送给所有者,但是机器上又没有发邮件的环境,所以导致产生大量的邮件数据文件。 解决方法是:把crontab的输出指定到相应的文件或者是/dev/null 输出包括两种,一种是程序的输出,一种是程序的错误。 &...

2018-12-18 12:03:43 145

原创 时间复杂度

时间复杂度 常见的最基本的几种时间复杂度如下:O(1)、O(n)、O(logn)这里的log都是以2为底的。 其他的常见的复杂度O(n^2)、O(nlogn)是从这几种演变过来的。 O(1)是顺序执行,不需要任何循环的算法复杂度。例如:$a=1; O(n)是循环一次的算法复杂度。例如:foreach($arr as $value) {print $value;} O(logn)是每次走两倍的循环一...

2018-12-13 21:10:39 196

原创 《leetCode-php》一条直线上的最多点数

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 在平面上给n个点,求一条直线上最多有几个点。 第一反应是 两两结合,获取直线,判断其他点在不在直线上,复杂度n^3 <?php class Point { private $x; ...

2018-12-13 19:54:22 198

原创 判断一个字符串是否有重复的字符

请实现一个算法,确定一个字符串的所有字符是否全都不同。这里我们要求不允许使用额外的存储结构。 <?php $str = 'D-5H0F6T%Z?QM9,\72:[A8X! ;YJ#2'; $ret = preg_match('/.*(.)(.*\1).*/',$str); print_r($ret); 这里用到了正则表达式,\1代表第一个获取的值,()里面就是获取的值,第一个括号就是第...

2018-12-12 23:40:04 1663

原创 《leetCode-php》逆波兰式计算

Evaluate the value of an arithmetic expression in Reverse Polish Notation.  Valid operators are+,-,*,/. Each operand may be an integer or another expression.  Some examples:  ["2", "1", "+", "3"...

2018-12-12 22:02:05 191

原创 《leetCode-php》 求二叉树的最小深度和最大深度

有感而发,需要活到老学到老,不学就可能被淘汰。自己不是科班出身,就要好好学习。毕业之后大半年的下班时间都没有把握好呀。现在开始把握一下吧 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node do...

2018-12-12 21:12:46 554

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除