Introduction
这会是我第二篇介绍安全相关的博客,上一篇介绍了CSRF,这次我将介绍一种更加普遍,也更加广泛的攻击——XSS。
You are given an integer array stations
that represents the positions of the gas stations on the x-axis. You are also given an integer k
.
You should add k
new gas stations. You can add the stations anywhere on the x-axis, and not necessarily on an integer position.
Let penalty()
be the maximum distance between adjacent gas stations after adding the k
new stations.
Return the smallest possible value of penalty()
. Answers within 10-6
of the actual answer will be accepted.
Given an integer array nums
, return the number of all the arithmetic subsequences of nums
.
A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
[1, 3, 5, 7, 9]
, [7, 7, 7, 7]
, and [3, -1, -5, -9]
are arithmetic sequences.[1, 1, 2, 5, 7]
is not an arithmetic sequence.A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.
[2,5,10]
is a subsequence of [1,2,1,**2**,4,1,**5**,**10**]
.The test cases are generated so that the answer fits in 32-bit integer.
You are given an integer n
. You have an n x n
binary grid grid
with all values initially 1
‘s except for some indices given in the array mines
. The ith
element of the array mines
is defined as mines[i] = [xi, yi]
where grid[xi][yi] == 0
.
Return the order of the largest axis-aligned plus sign of 1*’s contained in* grid
. If there is none, return 0
.
An axis-aligned plus sign of 1
‘s of order k
has some center grid[r][c] == 1
along with four arms of length k - 1
going up, down, left, and right, and made of 1
‘s. Note that there could be 0
‘s or 1
‘s beyond the arms of the plus sign, only the relevant area of the plus sign is checked for 1
‘s.
You are given a string s
of lowercase English letters and an integer array shifts
of the same length.
Call the shift()
of a letter, the next letter in the alphabet, (wrapping around so that 'z'
becomes 'a'
).
shift('a') = 'b'
, shift('t') = 'u'
, and shift('z') = 'a'
.Now for each shifts[i] = x
, we want to shift the first i + 1
letters of s
, x
times.
Return the final string after all such shifts to s are applied.
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
Implement the LRUCache
class:
LRUCache(int capacity)
Initialize the LRU cache with positive size capacity
.int get(int key)
Return the value of the key
if the key exists, otherwise return -1
.void put(int key, int value)
Update the value of the key
if the key
exists. Otherwise, add the key-value
pair to the cache. If the number of keys exceeds the capacity
from this operation, evict the least recently used key.The functions get
and put
must each run in O(1)
average time complexity.