
数据结构
fareast_mzh
If something is free, you are the product.
展开
-
链表删除倒数第n个节点
https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/submissions/ DeleteNode.php <?php /** * https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/ * Definition for a singly-linked list. * class ListNode { * public $v原创 2021-04-19 17:16:20 · 277 阅读 · 0 评论 -
二叉树的直径 diameter-of-binary-tree, BFS/DFS
* Tree.h // // Created by EDZ on 2021/4/2. // #ifndef DIAMETEROFTREE_TREE_H #define DIAMETEROFTREE_TREE_H #include "deque" //#ifndef max //#define max(a, b) ((a) > (b) ? (a) : (b)) //#endif template<class T> T max(T a, T b) { return a &..原创 2021-04-05 17:41:56 · 400 阅读 · 0 评论 -
PHP 合并2个链表, C++ merge LinkedList 合并链表,链表合并, 合并链表
输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。 <?php class ListNode{ var $val; var $next = NULL; function __construct($x){ $this->val = $x; } } functi...原创 2018-07-24 21:46:00 · 385 阅读 · 0 评论 -
图广度优先 BFS BreadthFirstPaths
* BreadthFirstPaths.java package com.merrytech; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; public class BreadthFirstPaths<E> { private final HashMap<E, Boolean> marked; // Is..原创 2021-03-30 19:37:51 · 283 阅读 · 0 评论 -
图深度优先路径 Depth-first search to find paths in a graph
* DepthFirstPaths.java package com.merrytech; import java.util.HashMap; import java.util.Stack; public class DepthFirstPaths<E> { private final HashMap<E, Boolean> marked; // Has dfs() been called for the vertex? private final Has..原创 2021-03-30 12:42:43 · 336 阅读 · 2 评论 -
无向图创建 Undirected Graphs, 深度优先 DFS DepthFirstSearch
* Graph.java import java.util.HashSet; import java.util.Map; public class Graph<E> { private final int v; // number of vertices private int e; // number of edges private final HashMap<E, HashSet<E>> adj; // adjacency list..原创 2021-03-28 15:55:08 · 363 阅读 · 0 评论