Skip to content

Instantly share code, notes, and snippets.

View completejavascript's full-sized avatar

Lam Pham completejavascript

View GitHub Profile
// Kiểm tra xem một DOM node có vượt quá kích thước của container hay không?
// Nếu có thì sẽ thêm scrollbar cho nó, ngược lại thì không.
// Kiểm tra xem 1 element có vượt quá chiều rộng của container không
const isOverflowedX = elm => elm.scrollWidth > elm.clientWidth;
// Kiểm tra xem 1 element có vượt quá chiều cao của container không
const isOverflowedY = elm => elm.scrollHeight > elm.clientHeight;
// Nếu 1 element có chiều rộng vượt quá container,
const a = () => console.log('a');
const b = () => console.log('b');
const c = () => console.log('c');
const d = () => {
console.log('d');
setTimeout(a, 0);
b();
c();
}
d();
class CQueue {
constructor(capacity) {
this.data = [];
this.capacity = capacity;
this.size = 0;
this.front = 0;
this.rear = 0;
}
isFull() {
class AQueue {
constructor(capacity) {
this.data = [];
this.capacity = capacity;
this.size = 0;
}
isFull() {
return this.size === this.capacity;
}
function Stack(){
var stack = {};
var stackSize = 0;
return {
push: function(item){
stack[stackSize] = item;
stackSize++;
},
pop: function(){
class OStack {
constructor(capability) {
this.data = {};
this.size = 0;
this.capability = capability;
}
isEmpty() {
return this.size === 0;
}
class MStack {
constructor(capability) {
this.data = new Map();
this.capability = capability;
}
isEmpty() {
return this.data.size === 0;
}
class AStack {
constructor(capability) {
this.data = [];
this.capability = capability;
}
isEmpty() {
return this.data.length === 0;
}
#include <iostream>
using namespace std;
long long sumAll(long long a, long long b) {
long long n;
if (b > a) n = b - a + 1;
else n = a - b + 1;
return n * (a + b) / 2;
#include <iostream>
using namespace std;
const int MAX_N = 1000001;
char input[MAX_N], output[MAX_N];
// Node
struct Node {
char data;
Node *next;