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; | |
class Solution { | |
public int[] solution(int N, int[] P, int[] Q) { | |
// write your code in Java SE 8 | |
int result[]=new int [Q.length]; | |
for(int index=0;index<P.length;index++){ | |
result[index]=sieve(P[index],Q[index]);; | |
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; | |
class Solution { | |
public int[] solution(int N, int[] P, int[] Q) { | |
// write your code in Java SE 8 | |
int result[]=new int [Q.length]; | |
int semi[]=sieve(N); | |
for(int index=0;index<P.length;index++){ | |
result[index]=semi[Q[index]]-semi[P[index]-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
import java.util.stream.IntStream; | |
import java.util.stream.Collectors; | |
import java.util.List; | |
import java.util.Arrays; | |
class Solution { | |
public int[] solution(int[] A) { | |
// write your code in Java SE 8 | |
int result[]=new int[A.length]; | |
List<Integer> sorted=IntStream.of(A).sorted().boxed().collect(Collectors.toList()); | |
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.stream.IntStream; | |
class Solution { | |
public int solution(int N, int M) { | |
// write your code in Java SE 8 | |
int index=0; | |
int count=0; | |
int [] test=IntStream.rangeClosed(0,N-1).toArray(); | |
while(test[index]!=-1){ | |
test[index]=-1; | |
count++; |
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 M) { | |
// write your code in Java SE 8 | |
return N/gcd(N,M); | |
} | |
public int gcd(int N,int M){ | |
if(N%M==0){ | |
return M; | |
}else{ | |
return gcd(M,N%M); |
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) { | |
// write your code in Java SE 8 | |
int count=0; | |
for(int index=0;index<B.length;index++){ | |
int gcd=0; | |
int extra=0; | |
if(A[index]==0||B[index]==0){ | |
continue; |
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) { | |
// write your code in Java SE 8 | |
int length=A.length; | |
int result[]=new int[length]; | |
for(int index=0;index<length;index++){ | |
//using Binet's formula | |
double num=A[index]+1; | |
double phi= (1+Math.sqrt(5))/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
public class Solution { | |
public int[] solution(int[] A, int[] B) { | |
int n = A.length; | |
int[] ladder = new int[n + 1]; | |
ladder[0] = ladder[1] = 1; | |
for (int i = 2; i <= n; i++) { | |
ladder[i] = ladder[i - 1] + ladder[i - 2]; | |
} | |
for (int i = 0; i < n; i++) { | |
A[i] = ladder[A[i]] & ((1 << B[i]) - 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
import java.util.Set; | |
import java.util.HashSet; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in Java SE 8 | |
Set<Integer> abs=new HashSet<Integer>(); | |
for(int index=0;index<A.length;index++){ | |
abs.add( Math.abs(A[index])); | |
} | |
return abs.size(); |
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
// Check if the user is ready to play! | |
confirm("Are you ready to play?"); | |
var age=prompt("What is your age"); | |
if(age<13){ | |
console.log("You can play this game but the developers take no responsibility for your actions ") | |
}else{ | |
console.log("Welcome"); | |
} | |
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'"); |