自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 二叉树的中序遍历

LeetCode 94 二叉树的中序遍历

2022-11-30 23:40:43 149

原创 LeetCode 删除有序数组中的重复项

LeetCode 删除有序数组中的重复项项

2022-06-04 18:47:51 136 1

原创 LeetCode 有效的括号

LeetCode有效的括号使用栈实现class Solution { /** * @param String $s * @return Boolean */ function isValid($s) { $stack = new SplStack(); $len = strlen($s); $map = [ '(' => ')', '{' => '

2022-05-23 18:40:59 139

原创 LeetCode 最长公共前缀

LeetCode 最长公共前缀class Solution { /** * @param String[] $strs * @return String */ function longestCommonPrefix($strs) { $curIndex = 0; $resStr = ''; // 取第一个字符串长度为最大循环次数 $times = strlen($strs[0]);

2022-05-19 21:55:27 93

原创 LeetCode 回文数

【LeetCode 回文数】数学解法class Solution { /** * @param Integer $x * @return Boolean */ function isPalindrome($x) { if($x<0){ return false; } $cur = 0; $n = $x; while($n!=0) {

2022-05-19 21:20:18 76

原创 【PHP】二分法

class HalfFind{ /** * @desc 二分法查找 效率老高了 前提: 必须是有序的数组 * @desc 二分法时间复杂度为 O(log n) * * @param $nums * @param $val * @return float|int */ function find($nums, $val) { if (count($nums) < 1) { .

2020-10-10 23:04:28 385

原创 【PHP】两数之和

/** * @desc 暴力计算 * @param Integer[] $nums * @param Integer $target * @return Integer[] */ function twoSum($nums, $target) { for($i=0; $i<count($nums); $i++){ for($j=$i+1; $j<count($nums); $j++){ ...

2020-07-22 12:11:03 753

原创 【PHP】删除链表的倒数第N个节点(Leetcode19)

/** * @param ListNode $head * @param Integer $n * @return ListNode */ function removeNthFromEnd($head, $n) { if($head == null){ return $head; } $newList = new ListNode(); $newList->nex.

2020-07-17 18:39:58 208

原创 【php】二进制链表转整数(Leetcode1290)

方法一:(开始没想到比较简洁的)/** * @param ListNode $head * @return Integer */ function getDecimalValue($head) { if($head == null){ return 0; } $res = []; // 将链表数据存入数组 while($head != null){

2020-07-17 18:00:36 131

原创 【PHP】Leetcode移除重复节点

class Solution{ function removeDuplicateNodes($head) { if($head == null || $head->next == null) { return $head; } $hash = []; $cur = $head; while($cur != null){ $hash[$cur->val] = 1;.

2020-07-16 00:34:19 81

原创 PHP实现单链表反转

/*** Definition for a singly-linked list.* class ListNode {* public $val = 0;* public $next = null;* function __construct($val) { $this->val = $val; }* }*/// 递归 function reverseList($head) { if($head == null ||...

2020-07-14 20:46:53 719

原创 PHP实现链表的头插法

class Node{ public $data; public $next;}class Test{ public function HeadInsert() { // 头结点 $linkList = new Node(); $linkList->next = null; // 插入的新节点 $node = new Node(); $node->dat.

2020-07-14 17:54:42 144

空空如也

空空如也

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

TA关注的人

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