This file contains 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 int[][] ranges; | |
private int totalSum; | |
private Random random; | |
public Solution(int[] weights) { | |
ranges = new int[weights.length][2]; | |
for (int i=0, current = 0; i < weights.length; i++) { |
This file contains 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 int lengthOfLongestSubstringKDistinct(String str, int k) { | |
int maxLength = 0; | |
int distinct = 0; | |
int[] charCounts = new int[256]; | |
for (int left = 0, right = 0; right < str.length(); right++) { | |
char rightChar = str.charAt(right); | |
if (charCounts[rightChar] == 0) { | |
distinct++; | |
} | |
charCounts[rightChar]++; |
This file contains 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 s3; | |
import com.amazonaws.AmazonServiceException; | |
import com.amazonaws.SdkClientException; | |
import com.amazonaws.auth.profile.ProfileCredentialsProvider; | |
import com.amazonaws.services.s3.AmazonS3; | |
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | |
import com.amazonaws.services.s3.model.*; | |
import com.google.common.base.Stopwatch; | |
import org.slf4j.Logger; |
This file contains 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 com.google.appengine.tools.cloudstorage.GcsFileOptions; | |
import com.google.appengine.tools.cloudstorage.GcsFilename; | |
import com.google.appengine.tools.cloudstorage.GcsInputChannel; | |
import com.google.appengine.tools.cloudstorage.GcsOutputChannel; | |
import com.google.appengine.tools.cloudstorage.GcsService; | |
import lombok.extern.slf4j.Slf4j; | |
import org.apache.james.mime4j.storage.AbstractStorageProvider; | |
import org.apache.james.mime4j.storage.Storage; | |
import org.apache.james.mime4j.storage.StorageOutputStream; |
This file contains 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.IOException; | |
import java.net.URLClassLoader; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.Path; | |
/** | |
* Example demonstrating a ClassLoader leak. | |
* | |
* <p>To see it in action, copy this file to a temp directory somewhere, |