Skip to content

Instantly share code, notes, and snippets.

View traveler.cpp
class Solution {
public:
/**
* @param n: an integer,denote the number of cities
* @param roads: a list of three-tuples,denote the road between cities
* @return: return the minimum cost to travel all cities
*/
int minCost(int n, vector<vector<int>> &roads) {
// unordered_map<int, vector<pair<int, int>>> graph;
// constructGraph(roads, graph);
View 751-john's-business.js
export class Solution {
/**
* business
*
* @param A: The prices [i]
* @param k:
* @return: The ans array
*/
business(A, k) {
View arraySum.go
package main
import (
"fmt"
"math"
"math/rand"
"sync"
"sync/atomic"
"time"
)
@sj82516
sj82516 / http.go
Last active Mar 11, 2021
Nodejs vs Golang: http request
View http.go
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type UsersResp struct {
@sj82516
sj82516 / a.js
Created Jul 20, 2020
Nodejs Dependency Circulation
View a.js
module.exports = {
data: "This is a",
};
const b = require('./b.js');
console.log(b.data);
View #11-Container With Most Water.cpp
// 從兩頭開始算容積,接著把矮的一邊往內縮持續比對
// 時間複雜度: O(n) / 空間複雜度 O(1)
class Solution {
public:
int maxArea(vector<int>& height) {
int result = 0;
int length = height.size();
int left = 0;
int right = length - 1;
int containerWidth = 0;
View findUser.spec.js
const expect = require('chai').expect;
const sinon = require('sinon');
const UserManager = require('../../user/user.manager');
describe('userManger', () => {
let userManager = null;
let sandbox = sinon.createSandbox();
const findUserStub = sandbox.stub();
View smellCode.js
const express = require('express');
const MongoClient = require('mongodb').MongoClient;
const bodyParser = require('body-parser');
const md5 = require('md5');
const app = express();
app.use(bodyParser.json());
const dbUrl = "mongodb://localhost:27017"
View ka_nginx_2.conf
events {
worker_connections 1024;
}
http {
keepalive_timeout 65;
server {
listen 80;
location / {
View ka_nginx_1.conf
events {
worker_connections 1024;
}
http {
keepalive_timeout 65;
server {
listen 80;
location / {