leetcode

package
v0.0.0-...-250739b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

297. Serialize and Deserialize Binary Tree

Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary tree can be serialized to a string and this string can be deserialized to the original tree structure. Clarification: The input/output format is the same as how LeetCode serializes a binary tree. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.

Runtime: 13 ms, faster than 90.50% of Go online submissions for Serialize and Deserialize Binary Tree. Memory Usage: 7.2 MB, less than 72.73% of Go online submissions for Serialize and Deserialize Binary Tree.

func Constructor

func Constructor() Codec

func (*Codec) Deserialize

func (this *Codec) Deserialize(data string) *TreeNode

func (*Codec) Serialize

func (this *Codec) Serialize(root *TreeNode) string

type ListNode

type ListNode = structure.ListNode

type TreeNode

type TreeNode = structure.TreeNode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL