algorithms
hust_joker
这个作者很懒,什么都没留下…
展开
-
二叉树填充每个节点的下一个右侧节点指针
/** * Definition for a Node. * type Node struct { * Val int * Left *Node * Right *Node * Next *Node * } */ type CircleQueue struct { Buff [4096]*Node Cap int Length int Start int End int } func (p *CircleQueue)原创 2021-07-13 10:10:11 · 90 阅读 · 0 评论 -
从前序和中序遍历构建二叉树
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func caller(preorder []int, inorder []int, indexMap map[int]int,inOrderStart, inOrderEnd, preOrderStart, preOrderEnd in原创 2021-07-08 20:47:11 · 77 阅读 · 0 评论 -
leetcode面试题二叉树路径总和迭代实现
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ type StackNode struct { Parr [1000]*TreeNode Index int } func(s *StackNode) IsEmpty() bool { if s.Index &l原创 2021-06-01 17:12:42 · 86 阅读 · 0 评论 -
leetcode二叉树路径总和递归实现
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func hasPathSum(root *TreeNode, targetSum int) bool { if nil == root { return false } if root.Left原创 2021-06-01 14:45:44 · 64 阅读 · 0 评论 -
leetcode判断是否二叉镜像树迭代实现
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ type MyCirQueue struct { Parr []*TreeNode Head int Tail int Cap int Size int } func QueueConstruc原创 2021-06-01 14:25:20 · 56 阅读 · 0 评论 -
判断是不是对称二叉树递归方法
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func isSymmetricNode(left, right *TreeNode) bool { if left == nil && right == nil { return true原创 2021-05-28 16:19:27 · 52 阅读 · 0 评论 -
循环队列leetcode面试解答
type MyCircularQueue struct { Parr []int Head int Tail int Length int Cap int } func Constructor(k int) MyCircularQueue { return MyCircularQueue{ Parr: make([]int, k), Head: 0, Tail: 0, Length: k,原创 2021-05-28 09:22:27 · 61 阅读 · 0 评论 -
二叉树后序遍历迭代实现
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right原创 2021-05-27 14:44:28 · 145 阅读 · 0 评论 -
二叉树中序遍历迭代实现
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ type Stack struct { Parr [1000]*TreeNode Index int } func(s *Stack) IsEmpty() bool { if s.Index <= 0 {原创 2021-05-27 09:26:44 · 53 阅读 · 0 评论 -
二叉树前序遍历迭代实现
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ type Stack struct { Parr [1000]*TreeNode Index int } func(s *Stack) IsEmpty() bool { if s.Index <= 0 {原创 2021-05-26 16:55:21 · 79 阅读 · 0 评论 -
循环队列的c实现
#include <stdio.h> #include <stdlib.h> #define SUCCESS 0 #define FAILED -1 typedef struct { int * parr; int head; int tail; int length; } CircleQueue; CircleQueue queue; int init(CircleQueue* p, int length) { p->parr原创 2021-03-17 15:30:08 · 104 阅读 · 0 评论 -
算法 1-3-4答案
array_stack.c 和array_stack.h 参展arraystack文章中的答案。 #include “stack_array.h” #include <unistd.h> #include <stdio.h> int main () { int result = test_parentheses_balance(); if(1 == result) {...原创 2018-12-24 16:22:16 · 242 阅读 · 0 评论 -
基于链表的队列实现
队列接口声明: #ifndef __LINKLIST_QUEUE_H_ #define __LINKLIST_QUEUE_H_ struct unit { char data; struct unit* punit; }; struct linklistqueue { int size; struct unit* phead; struct unit* ptail; void(*pf...原创 2018-12-26 21:00:08 · 152 阅读 · 0 评论