algorithm

package
v0.0.0-...-9d91cd3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMedianSortedArrays

func FindMedianSortedArrays(nums1 []int, nums2 []int) (m float64)

FindMedianSortedArrays Problem 4 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty.

func LengthOfLongestSubstrings

func LengthOfLongestSubstrings(s string) (l int)

LengthOfLongestSubstrings Problem 3 Given a string, find the length of the longest substring without repeating characters.

func TwoSum

func TwoSum(nums []int, target int) []int

TwoSum Problem 1 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice.

Types

type CycleQueue

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

CycleQueue 循环队列 循环队列:入栈 tail 游标移动,出栈 head 游标移动。 栈满:(tail + 1) % len(element) == head (此处踩了坑) 栈空:head,tail = -1,-1

func Constructor

func Constructor(size int) CycleQueue

Constructor 构造循环队列

func (*CycleQueue) DeQueue

func (c *CycleQueue) DeQueue() bool

DeQueue 出队

func (*CycleQueue) EnQueue

func (c *CycleQueue) EnQueue(value interface{}) bool

EnQueue 入队

func (*CycleQueue) End

func (c *CycleQueue) End() interface{}

End 返回队尾的元素

func (*CycleQueue) Front

func (c *CycleQueue) Front() interface{}

Front 返回队头的元素

func (*CycleQueue) IsEmpty

func (c *CycleQueue) IsEmpty() bool

IsEmpty 队列是否为空

func (*CycleQueue) IsFull

func (c *CycleQueue) IsFull() bool

IsFull 队列是否已满

type ListNode

type ListNode struct {
	Val  int
	Next *ListNode
}

ListNode list node struct

func AddTwoNumbers

func AddTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode

AddTwoNumbers Problem 2 You are given two non-empty linked lists representing two non-negative integers.

The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

type Queue

type Queue struct {
	Element []interface{}
	Index   int
}

Queue .

func (*Queue) DeQueue

func (q *Queue) DeQueue() (ok bool)

DeQueue dequeue

func (*Queue) EnQueue

func (q *Queue) EnQueue(val interface{})

EnQueue enqueue

func (*Queue) Front

func (q *Queue) Front() interface{}

Front return first Element from queue

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

IsEmpty .

type Stack

type Stack []interface{}

Stack stack operate

func (Stack) Cap

func (s Stack) Cap() int

Cap stack cap

func (Stack) IsEmpty

func (s Stack) IsEmpty() bool

IsEmpty is stack empty?

func (Stack) Len

func (s Stack) Len() int

Len stack length

func (*Stack) Pop

func (s *Stack) Pop() (interface{}, error)

Pop pop stack data

func (*Stack) Push

func (s *Stack) Push(e interface{})

Push add data to stack

func (Stack) Top

func (s Stack) Top() (interface{}, error)

Top get stack top data

Jump to

Keyboard shortcuts

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