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; | |
import java.util.stream.IntStream; | |
import java.util.stream.Collectors; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in Java SE 8 | |
int first=0; | |
int last=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.io.BufferedOutputStream; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.sql.Connection; | |
import java.sql.PreparedStatement; |
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
package com.api.services.websockets; | |
import java.util.Collections; | |
import java.util.HashMap; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.concurrent.ConcurrentHashMap; | |
import java.util.concurrent.Future; | |
import javax.servlet.http.HttpServletRequest; |
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
// save uploaded file to a defined location on the server | |
private Response saveFile(InputStream uploadedInputStream, String fileName, | |
String name, String description, String albumId, String userId) { | |
try { | |
File tempFile = File.createTempFile("doc-" + userId + "-" | |
+ albumId, ".tmp"); | |
// tempFile.createNewFile(); | |
tempFile.deleteOnExit(); | |
File thumbFile = File.createTempFile("doc-" + userId + "-" | |
+ albumId + "thumb", ".tmp"); |
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 void deleteAWS(String link) throws IOException { | |
AmazonS3 s3Conn = new AmazonS3Client( | |
new PropertiesCredentials( | |
Document.class | |
.getResourceAsStream("/com/api/AwsCredentials.properties"))); | |
DeleteObjectsRequest multiDelete = new DeleteObjectsRequest( | |
"schoolmart-document"); | |
List<KeyVersion> keys = new ArrayList<DeleteObjectsRequest.KeyVersion>(); |
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.lang.Math; | |
import java.util.stream.IntStream; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in Java SE 8 | |
if(A.length==0) | |
{ | |
return 0; | |
} | |
if(A.length==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; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in Java SE 8 | |
if(A.length==0){ | |
return 0; | |
} | |
int[] sorted=IntStream.of(A).sorted().toArray(); | |
for(int index=0;index<sorted.length;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.stream.IntStream; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in Java SE 8 | |
if(A.length==0){ | |
return 1; | |
} | |
int []sorted = IntStream.of(A).sorted().toArray(); | |
if(sorted[sorted.length-1]!=sorted.length+1){ | |
return sorted.length+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; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in Java SE 8 | |
if(A.length==1){ | |
return A[0]+1; | |
} | |
int[] sorted=IntStream.of(A).sorted().toArray(); | |
int temp=sorted[0]; | |
for(int index=1;index<sorted.length;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
class Solution { | |
public int[] solution(int N, int[] A) { | |
// write your code in Java SE 8 | |
int length=A.length; | |
int max=N+1; | |
int []result=new int[N]; | |
int maxValue=0; | |
for(int index=0;index<length;index++){ |
OlderNewer