使用本指令碼即代表你同意本免責聲明。
本指令碼用於繞過臺灣電子書與教學工具的前端驗證,達成不需要教師帳號即可使用。
使用本指令碼即代表你同意本免責聲明。
本指令碼用於繞過臺灣電子書與教學工具的前端驗證,達成不需要教師帳號即可使用。
使用前請務必閱讀 免責聲明
class Solution { | |
static const int MODULAR = INT_MAX; | |
static const int BASE = 26; | |
vector<int> normalized; | |
vector<int> power; | |
public: | |
// O(n) | |
string find(string &s, int len) { | |
int hash = 0; | |
unordered_map<int, unordered_set<int>> mp; |
/** | |
MacOS : clang++ -Wall -std=c++17 parallel_accumulate.cpp -O3 -o out | |
---------------------------- | |
num of cores : (8) w/o task switching | |
1166029 (ns) | |
the anwser : 45000497 | |
2564850 (ns) | |
the anwser : 45000497 | |
---------------------------- | |
**/ |
/** | |
Hence without any optimisation insert/delete + search of kth element has O(2H + k) complexity. | |
How do we optimise it ? | |
First, we need to make sure the balanced tree for sure. Here, we don't need to implement it (AVL, Red-Black Tree) | |
Secondly, we can mimic B+trees (https://en.wikipedia.org/wiki/B+ tree). | |
we can add a doubly linked list trait on the tree node. Then, as usual, | |
we insert node with time complexity O(H), but take time complexity O(1) to maintain doubly linked list. | |
On the other hand, we can get the same complexity on deletion. | |
**/ |
/** | |
MacOS : clang++ -std=c++17 -stdlib=libc++ -O2 sample.cpp | |
GCC: g++ -std=c++17 -lpthread sample.cpp | |
constrains resource in docker : docker run -it --rm --name=thread --cpuset-cpus="3" gcc bash | |
**/ | |
#include <iostream> | |
#include <sstream> | |
#include <vector> | |
#include <pthread.h> // POSIX |
/** | |
342. Power of Four | |
A code is realy simple but hard to realize the concept. | |
There's a magic mask to handle it, and it is also the best solution in leetcode. | |
Besides, I don't want to mention a brutal force solution with loop neither. | |
Here I use simple concept to explain it, and can help you memorize when you interview. | |
The problem asks us solve problem w/o loops/recursion | |
Intuitively, 4^n is 2^n; on the contrary, 2^n is not alwasy 4^n only when |
FROM ruby:2.3.1 | |
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs | |
# Set an environment variable where the Rails app is installed to inside of Docker image | |
ENV LC_ALL C.UTF-8 | |
# Setup TZ | |
ENV TZ Asia/Taipei | |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
ENV RAILS_ROOT /var/www/app |
from datetime import datetime | |
from lxml import etree | |
import requests as req | |
import csv | |
import re | |
def handle_slide(slide): |
import socket | |
import datetime | |
import sys | |
import time | |
def main(): | |
message = "Ping" | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.settimeout(120) | |
if len(sys.argv) != 3: | |
print "Correct usage: script, IP address, port number" |