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
Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. | |
We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. | |
You must solve this problem without using the library's sort function. | |
Example 1: | |
Input: nums = [2,0,2,1,1,0] | |
Output: [0,0,1,1,2,2] |
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
Add it to your ~/.bashrc file" | |
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::") |
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 { | |
public int ladderLength(String beginWord, String endWord, List<String> wordList) { | |
// check input | |
if (!wordList.contains(endWord)) { | |
return 0; | |
} | |
// We are going to use BFS to build the graph of the beginWord to endWord using | |
// all words in the wordList |
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
# for each container ID use the docker "rm" command to remove/delete the container | |
!for cid in $(docker ps -a | awk '{print $1}' | tail -n +2);do docker rm $cid; done |
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
# generate a list of container ID from the docker ps command | |
!docker ps -a | awk '{print $1}' | tail -n +2 |
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
/** | |
* Definition for an interval. | |
* public class Interval { | |
* int start; | |
* int end; | |
* Interval() { start = 0; end = 0; } | |
* Interval(int s, int e) { start = s; end = e; } | |
* } | |
*/ | |
class Solution { |
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 { | |
public int trap(int[] height) { | |
int count = 0; | |
int left = 0; | |
int right = height.length - 1; | |
int maxLeft = 0; | |
int maxRight = 0; | |
while (left < right) { |
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 { | |
public int[] productExceptSelf(int[] nums) { | |
int[] results = new int[nums.length]; | |
int[] left = new int[nums.length]; | |
Arrays.fill(left, 1); | |
// [1, 2, 3, 4] | |
// [1, 1, 2, 6] | |
for (int i = 1; i < nums.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
class Solution { | |
public int leastInterval(char[] tasks, int n) { | |
if (n < 0 ) { | |
return 0; | |
} | |
// Group tasks | |
int[] count = new int[26]; | |
for (char cur : tasks) { | |
int pos = cur - 'A'; |
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 { | |
// [4,5,6,7,0,1,2,3] | |
// [6,7,0,1,2,3,4,5] | |
public int search(int[] nums, int target) { | |
if (nums == null || nums.length == 0) { | |
return -1; | |
} | |
final int numsLen = nums.length; | |
NewerOlder