feat: remove code
This commit is contained in:
parent
8666e5a169
commit
94c3e6048f
14 changed files with 0 additions and 340 deletions
|
|
@ -1,51 +0,0 @@
|
|||
#include <deque>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
|
||||
class ExtremaCircularBuffer {
|
||||
public:
|
||||
void push_back(double value) {
|
||||
if (prices.size() == capacity) {
|
||||
double front = prices.front();
|
||||
|
||||
if (--sorted_prices[front] == 0)
|
||||
sorted_prices.erase(front);
|
||||
prices.pop_front();
|
||||
}
|
||||
|
||||
prices.push_back(value);
|
||||
++sorted_prices[value];
|
||||
}
|
||||
|
||||
void pop_front() {
|
||||
if (prices.empty()) {
|
||||
throw std::out_of_range("Cannot pop_front() from empty buffer");
|
||||
}
|
||||
|
||||
double front = prices.front();
|
||||
|
||||
if (--sorted_prices[front] == 0)
|
||||
sorted_prices.erase(front);
|
||||
prices.pop_front();
|
||||
}
|
||||
|
||||
size_t size() const { return prices.size(); }
|
||||
|
||||
double get_max() const {
|
||||
if (prices.empty()) {
|
||||
throw std::out_of_range("Cannot find max() of empty buffer");
|
||||
}
|
||||
|
||||
return sorted_prices.rbegin()->first;
|
||||
}
|
||||
|
||||
double get_min() const {
|
||||
if (prices.empty()) {
|
||||
throw std::out_of_range("Cannot find min() of empty buffer");
|
||||
}
|
||||
|
||||
return sorted_prices.begin()->first;
|
||||
}
|
||||
|
||||
/* methods & fields omitted for brevity */
|
||||
};
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
#include <deque>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
class ExtremaCircularBuffer {
|
||||
public:
|
||||
void push_back(double value) {
|
||||
if (prices.size() == capacity) {
|
||||
double front_value = prices.front();
|
||||
pop_max(front_value);
|
||||
prices.pop_front();
|
||||
}
|
||||
|
||||
prices.push_back(value);
|
||||
push_max(value);
|
||||
}
|
||||
|
||||
void pop_front() {
|
||||
if (prices.empty()) {
|
||||
throw std::out_of_range("Cannot pop_front() from empty buffer");
|
||||
}
|
||||
|
||||
double front_value = prices.front();
|
||||
pop_max(front_value);
|
||||
prices.pop_front();
|
||||
}
|
||||
|
||||
double get_max() const {
|
||||
if (prices.empty()) {
|
||||
throw std::out_of_range("Cannot find max() of empty buffer");
|
||||
}
|
||||
|
||||
return maxs.front().first;
|
||||
}
|
||||
|
||||
private:
|
||||
void push_max(double value) {
|
||||
size_t popped = 0;
|
||||
|
||||
while (!maxs.empty() && maxs.back().first < value) {
|
||||
popped += maxs.back().second + 1;
|
||||
maxs.pop_back();
|
||||
}
|
||||
|
||||
maxs.emplace_back(value, popped);
|
||||
}
|
||||
|
||||
void pop_max(double value) {
|
||||
size_t popped = maxs.front().second;
|
||||
|
||||
if (popped == 0) {
|
||||
maxs.pop_front();
|
||||
} else {
|
||||
--maxs.front().second;
|
||||
}
|
||||
}
|
||||
|
||||
/* methods & fields omitted for brevity */
|
||||
};
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <stdexcept>
|
||||
|
||||
class ExtremaCircularBuffer {
|
||||
public:
|
||||
ExtremaCircularBuffer(size_t capacity) : capacity(capacity) {}
|
||||
|
||||
void push_back(double value) {
|
||||
if (prices.size() == capacity) {
|
||||
prices.pop_front();
|
||||
}
|
||||
|
||||
prices.push_back(value);
|
||||
}
|
||||
|
||||
void pop_front() {
|
||||
if (prices.empty()) {
|
||||
throw std::out_of_range("Cannot pop_front() from empty buffer");
|
||||
}
|
||||
|
||||
prices.pop_front();
|
||||
}
|
||||
|
||||
size_t size() const { return prices.size(); }
|
||||
|
||||
double get() const {
|
||||
if (prices.empty()) {
|
||||
throw std::out_of_range("Cannot find max() of empty buffer");
|
||||
}
|
||||
|
||||
return *std::max_element(prices.begin(), prices.end());
|
||||
}
|
||||
|
||||
private:
|
||||
std::deque<double> prices;
|
||||
size_t capacity;
|
||||
};
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
std::vector<int> maximumBeauty(std::vector<std::vector<int>>& items, std::vector<int>& queries) {
|
||||
std::sort(items.begin(), items.end());
|
||||
std::vector<std::pair<int, int>> sorted_queries;
|
||||
sorted_queries.reserve(queries.size());
|
||||
for (size_t i = 0; i < queries.size(); ++i) {
|
||||
sorted_queries.emplace_back(queries[i], i);
|
||||
}
|
||||
std::sort(sorted_queries.begin(), sorted_queries.end());
|
||||
|
||||
int beauty = items[0][1];
|
||||
size_t i = 0;
|
||||
std::vector<int> ans(queries.size());
|
||||
|
||||
for (const auto [query, index] : sorted_queries) {
|
||||
while (i < items.size() && items[i][0] <= query) {
|
||||
beauty = std::max(beauty, items[i][1]);
|
||||
++i;
|
||||
}
|
||||
ans[index] = i > 0 && items[i - 1][0] <= query ? beauty : 0;
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
def countFairPairs(self, nums, lower, upper):
|
||||
nums.sort()
|
||||
ans = 0
|
||||
|
||||
for i, num in enumerate(nums):
|
||||
k = bisect_left(nums, lower - num, 0, i)
|
||||
j = bisect_right(nums, upper - num, 0, i)
|
||||
|
||||
ans += k - j
|
||||
|
||||
return ans
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
def countFairPairs(self, nums, lower, upper):
|
||||
nums.sort()
|
||||
ans = 0
|
||||
|
||||
def pairs_leq(x: int) -> int:
|
||||
pairs = 0
|
||||
l, r = 0, len(nums) - 1
|
||||
while l < r:
|
||||
if nums[l] + nums[r] <= x:
|
||||
pairs += r - l
|
||||
l += 1
|
||||
else:
|
||||
r -= 1
|
||||
return pairs
|
||||
|
||||
return pairs_leq(upper) - pairs_leq(lower - 1)
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
class Solution {
|
||||
public:
|
||||
static constexpr long long MOD = 1e9 + 7;
|
||||
long long mpow(long long a, long long b, long long mod=MOD) {
|
||||
long long ans = 1;
|
||||
while (b > 0) {
|
||||
if (b & 1) {
|
||||
ans = (ans * a) % MOD;
|
||||
}
|
||||
a = (a * a) % MOD;
|
||||
b >>= 1;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
int countGoodNumbers(long long n) {
|
||||
long long even_slots = (n + 1) / 2, odd_slots = n / 2;
|
||||
return (mpow(5, even_slots) * mpow(4, odd_slots)) % MOD;
|
||||
}
|
||||
};
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
long long minEnd(int n, long long x) {
|
||||
int bits_to_distribute = n - 1;
|
||||
long long mask = 1;
|
||||
|
||||
while (bits_to_distribute > 0) {
|
||||
if ((x & mask) == 0) {
|
||||
if ((bits_to_distribute & 1) == 1)
|
||||
x |= mask;
|
||||
bits_to_distribute >>= 1;
|
||||
}
|
||||
mask <<= 1;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
class Solution {
|
||||
public:
|
||||
int minimumOperations(vector<int>& nums) {
|
||||
vector<int> freq(101, 0);
|
||||
int i;
|
||||
for (i = nums.size() - 1; i >= 0; --i) {
|
||||
if (++freq[nums[i]] == 2) {
|
||||
return ceil((i + 1) / 3.0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
def minimumSubarrayLength(self, nums, k):
|
||||
ans = sys.maxsize
|
||||
|
||||
largest = max(*nums, k)
|
||||
num_digits = floor((log(max(largest, 1))) / log(2)) + 1
|
||||
|
||||
counts = [0] * num_digits
|
||||
l = 0
|
||||
|
||||
def update(x, delta):
|
||||
for i in range(len(counts)):
|
||||
if x & 1:
|
||||
counts[i] += delta
|
||||
x >>= 1
|
||||
|
||||
def bitwise_or():
|
||||
return reduce(
|
||||
operator.or_,
|
||||
(1 << i if count else 0 for i, count in enumerate(counts)),
|
||||
0
|
||||
)
|
||||
|
||||
for r, num in enumerate(nums):
|
||||
update(num, 1)
|
||||
while l <= r and bitwise_or() >= k:
|
||||
ans = min(ans, r - l + 1)
|
||||
update(nums[l], -1)
|
||||
l += 1
|
||||
|
||||
return -1 if ans == sys.maxsize else ans
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
def minimumSubarrayLength(self, nums, k):
|
||||
# provide a sentinel for "no window found"
|
||||
ans = sys.maxsize
|
||||
window = deque()
|
||||
l = 0
|
||||
|
||||
# expand the window by default
|
||||
for r in range(len(nums)):
|
||||
# consider `nums[r]`
|
||||
window.append(nums[r])
|
||||
# shrink window while valid
|
||||
while l <= r and reduce(operator.or_, window) >= k:
|
||||
ans = min(ans, r - l + 1)
|
||||
window.popleft()
|
||||
l += 1
|
||||
|
||||
# normalize to -1 as requested
|
||||
return -1 if ans == sys.maxsize else ans
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
[Unit]
|
||||
Description=Git Server UI
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=apache
|
||||
WorkingDirectory=/srv/git/git-server-ui
|
||||
ExecStart=/root/.local/bin/gunicorn --workers 3 --bind 0.0.0.0:8000 --chdir /srv/git wsgi:app
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<VirtualHost *:443>
|
||||
ServerName <servername>
|
||||
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/letsencrypt/live/<servername>/fullchain.pem
|
||||
SSLCertificateKeyFile /etc/letsencrypt/live/<servername>/privkey.pem
|
||||
|
||||
SetEnv GIT_PROJECT_ROOT /srv/git
|
||||
SetEnv REMOTE_USER $REDIRECT_REMOTE_USER
|
||||
|
||||
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
|
||||
|
||||
<Directory "/usr/libexec/git-core">
|
||||
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
|
||||
Require all granted
|
||||
AllowOverride None
|
||||
</Directory>
|
||||
|
||||
<Files "git-http-backend">
|
||||
AuthType Basic
|
||||
AuthName "Git Access"
|
||||
AuthUserFile /srv/git/.htpasswd
|
||||
Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#)
|
||||
Require valid-user
|
||||
</Files>
|
||||
ProxyPassMatch ^/git/ !
|
||||
ProxyPreserveHost On
|
||||
ProxyPass / http://127.0.0.1:8000/
|
||||
ProxyPassReverse / http://127.0.0.1:8000/
|
||||
</VirtualHost>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
[safe]
|
||||
directory = *
|
||||
Loading…
Add table
Add a link
Reference in a new issue