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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
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 com.practice.backtracking.tree; | |
public class MaxConsecutiveLength { | |
public static void main(String[] args) { | |
BT bt = new BT(10); | |
bt.setLeft(new BT(1)); | |
bt.setRight(new BT(9)); | |
bt.getLeft().setLeft(new BT(13)); | |
bt.getLeft().setRight(new BT(12)); |
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 com.practice.backtracking.mattrix; | |
public class RowWithMax1s { | |
public static void main(String[] args) { | |
int[][] mat = {{0, 0, 0, 1}, | |
{0, 0, 0, 0}, | |
{0, 0, 0, 1}, | |
{0, 1, 1, 1} | |
}; |
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 com.practice.backtracking.array; | |
public class FindPairSumInRotatedArray { | |
public static void main(String[] args) { | |
int[] a = {11, 15, 6, 7, 9, 10}; | |
int sum = 16; | |
System.out.println(isSumExist(a,findPivot(a, 0, a.length - 1),sum)); | |
} |
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 class GenerateAllRotation { | |
public static void main(String[] args) { | |
generateRotation(1445); | |
} | |
private static int len(int num){ | |
int count=0; | |
while (num >0){ | |
count++; |
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 com.algo.ds.practice.TreePractice; | |
import com.algo.ds.practice.TreeNode; | |
import java.util.HashSet; | |
import java.util.Set; | |
public class VerticalWidth { | |
public static void main(String[] args) { | |
TreeNode tn = new TreeNode(1); |
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 mattrix; | |
import java.util.LinkedList; | |
import java.util.Queue; | |
public class RotTomato { | |
public static void main(String[] args) { | |
// | |
int[][] mat = {{2, 1, 0, 2, 1}, {1, 0, 1, 2, 1}, {1, 0, 0, 2, 1}}; | |
int row = 3; |
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 app; | |
public class GetPairInRotatedArray { | |
public static void main(String[] args) { | |
int[] a = { 11, 15, 26, 38, 9, 10 }; | |
int hi = getIndex(a, 0, a.length - 1); | |
int low = hi + 1; | |
System.out.println(isSumExist(a, hi, low, 35)); | |
} |
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 com.test.string; | |
public class Amazon392Mattrix { | |
public static void main(String[] args) { | |
char[][] mat = {{'a','b','c'},{'d','e','f'},{'g','h','i'}}; | |
int row = 3; | |
int col = 3; | |
mattrix(mat,row,col); | |
} |
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 array; | |
public class Swap { | |
public static void main(String[] args) { | |
int[] a = {-1, -2, -3, -4, 5, 6, -7, 8, 9}; | |
quickSort(a,0,a.length-1); | |
for (int i : a){ | |
System.out.print(i+","); | |
} |
NewerOlder