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
<template> | |
<section> | |
<Btn/> | |
</section> | |
</template> | |
<script> | |
export default { | |
components: { | |
Btn: Button |
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 solution(int N) { | |
int A = (int)Math.round(Math.sqrt(N)); | |
while (N % A != 0) A--; | |
return 2*(A + N/A); | |
} | |
} |
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 solution(int[] A) { | |
int len = A.length; | |
if (len == 0) return 0; | |
int min = A[0]; | |
int profits = 0; | |
for (int i = 1; i < len; i++) { | |
int price = A[i]; | |
if (price < min) { | |
min = price; |
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 solution(int[] A) { | |
int length = A.length; | |
int leader = A[0]; | |
int votes = 1; | |
//Boyer–Moore majority vote algorithm | |
for (int i = 1; i < length; i++) { | |
int digit = A[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
import java.util.List; | |
import java.util.ArrayList; | |
class Solution { | |
public int solution(String S) { | |
if (S == null || S.length() == 0) return 1; | |
if (S.length() % 2 != 0) return 0; | |
char first = S.charAt(0); | |
if (first != '{' && first != '[' && first != '(') return 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
import java.util.*; | |
// you can write to stdout for debugging purposes, e.g. | |
// System.out.println("this is a debug message"); | |
class Solution { | |
public int solution(int[] A) { | |
Arrays.sort(A); | |
int length = A.length; |
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
import java.util.Set; | |
import java.util.HashSet; | |
// you can write to stdout for debugging purposes, e.g. | |
// System.out.println("this is a debug message"); | |
class Solution { | |
public int solution(int[] A) { | |
Set<Integer> distincts = new HashSet<>(); | |
for (int i: A) { |
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
import java.util.Arrays; | |
class Solution { | |
public int solution(int[] A) { | |
if (A == null || A.length < 3) return 0; | |
int max = Integer.MAX_VALUE; | |
Arrays.sort(A); | |
long last = A[A.length-1]; | |
for (int i = 0; i < A.length-2; i++) { | |
long P = A[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 { | |
public int solution(int[] A) { | |
int pairs = 0; | |
int easts = 0; | |
for (int i : A) { | |
if (i == 0) { | |
easts++; | |
} else { | |
pairs += easts; | |
} |
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 solution(int A, int B, int K) { | |
return B/K - (A == 0 ? -1 : (A-1)/K); | |
} | |
} |
NewerOlder