This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public int maxProfit(int[] prices) { | |
if (prices.length == 0) return 0; | |
int[] left = findMaxs(prices); | |
int[] right = findMaxs(IntStream.rangeClosed(1, prices.length) | |
.map(i -> -prices[prices.length - i]).toArray()); | |
int max = 0; | |
for (int i = 1; i < prices.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
private TreeMap<Integer, Integer> map; | |
private int index; | |
private int middle; | |
private int k; | |
public double[] medianSlidingWindow(int[] nums, int k) { | |
int m = (k + 1) % 2; | |
this.k = k; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
num = 0 | |
changed = False | |
changedNum = 0 | |
for i in range(0, 2 * n): | |
command = input() | |
if command == 'remove': | |
num -= 1 | |
if changed: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
def translate(index, s): | |
for i in range(1, n + 1): | |
s += str(index[i]) if (index[i - 1] & 1) == 0 else str(9 - index[i]) | |
return s | |
for i in range(0, (10 ** n)): | |
print(translate(list(map(int, str(i).zfill(n + 1))), '')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = 1 / 25.5622 | |
step = 1000 | |
p = p / step | |
n = 800 * step | |
P = [[1, 0, 0, 0]] | |
for i in range(1, 8): | |
P.append([0, 0, 0, 0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
try: | |
n, s, m, t = map(int, raw_input().split(' ')) | |
H = map(int, raw_input().split(' ')) | |
t -= 1 | |
s -= 1 | |
ht = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
mavenLocal() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:2.+' | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x(i) = x(i - 1) + x(i - 2) | |
現況 | |
private i = 2; | |
private int[] x = new int[i + 1]; | |
void func() { | |
x[i] = x[i - 1] + x[i - 2]; | |
//update buffer |