Skip to content

Instantly share code, notes, and snippets.

View tcstory's full-sized avatar
😘
想变成男孩子

颜贵彬 tcstory

😘
想变成男孩子
View GitHub Profile
@tcstory
tcstory / max.js
Created September 14, 2018 13:32
最大连续子序列之和
var data = [-2, 11, -4, 13, -5, -2];
function max(data) {
let results = [];
for (let i = 0; i < data.length; i++) {
if (i === 0) {
results[i] = {
s: 0,
e: 1,
class Set {
constructor() {
this._items = {};
}
add(value) {
if (!this.has(value)) {
this._items[value] = value;
return true;
}
class Node {
constructor(element) {
this.element = element;
this.next = null;
this.prev = null;
}
}
// 简单的优化过性能......
class DoublyLinkedList {
class Node {
constructor(element) {
this.element = element;
this.next = null;
}
}
class LinkedList {
constructor() {
this._length = 0;
class Queue {
constructor() {
this._items = [];
}
enqueue(element) {
if (Array.isArray(element)) {
this._items.push(...element);
} else {
this._items.push(element);
class Queue {
constructor() {
this._items = [];
}
enqueue(element) {
if (Array.isArray(element)) {
this._items.push(...element);
} else {
this._items.push(element);
class Stack {
constructor() {
this._items = [];
}
push(element) {
if (Array.isArray(element)) {
this._items.push(...element);
} else {
this._items.push(element);