diff --git a/862-shortest-subarray-with-sum-at-least-k.go b/862-shortest-subarray-with-sum-at-least-k.go index 99ac8d0..93034ba 100644 --- a/862-shortest-subarray-with-sum-at-least-k.go +++ b/862-shortest-subarray-with-sum-at-least-k.go @@ -1,38 +1,32 @@ package main -import "fmt" - type Queue struct { - front int - rear int - size int - QArray [100000]int + front int + rear int + size int + queue [100000]int } func (q *Queue) initQueue(size int) { q.size = size - //q.QArray = [size]int{} q.front = -1 q.rear = -1 } func (q *Queue) enqueue(value int) { if q.rear == q.size-1 { - fmt.Println("Queue is Full") return } else { q.rear++ - q.QArray[q.rear] = value + q.queue[q.rear] = value } } func (q *Queue) dequeue() int { var x int = -1 - if q.front == q.rear { - fmt.Println("Queue is Empty!") - } else { + if q.front != q.rear { q.front++ - x = q.QArray[q.front] + x = q.queue[q.front] } return x }