leetcode/lcof/9/ #2548
Replies: 1 comment 2 replies
-
方法二:数组+双指针 class CQueue {
private int[] queue;
private int head;
private int tail;
private int capacity;
public CQueue() {
capacity = 10000;
queue = new int[capacity];
tail = 1;
head = 0;
}
public void appendTail(int value) {
queue[((tail++ - 1) % capacity)] = value;
}
public int deleteHead() {
if ((head + 1 % capacity) == tail) return -1;
return queue[head++ % capacity];
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
leetcode/lcof/9/
多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
https://doocs.github.io/leetcode/lcof/9/
Beta Was this translation helpful? Give feedback.
All reactions