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 double findMedianSortedArrays(int[] nums1, int[] nums2) { | |
int[] merged = new int[nums1.length + nums2.length]; | |
int mergedIndex = 0; | |
int index1 = 0; | |
int index2 = 0; | |
while (index1 < nums1.length || index2 < nums2.length) { | |
if (index2 < nums2.length) { |
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 interface PersonServiceClient { | |
Person getPerson(String id); | |
} | |
@Component | |
public class MyComponent { | |
private final PersonServiceClient personServiceClient; |
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
@Getter | |
@Setter | |
@Entity | |
@IdClass(MyEntity.CompositeKey.class) | |
@Table(name = "ENTITY_TABLE") | |
public class MyEntity implements Serializable { | |
@Id | |
@Column(name = "FIRST_ID", nullable = false) | |
private String firstId; |
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
private int withoutStreams() { | |
int[] values = {1, 2, 3, 4, 5, 6, 7, 8}; | |
int sum = 0; | |
for (int value : values) { | |
if (value > 3) { | |
sum += value; | |
} | |
} | |
return 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 PermuteratorTest { | |
private Permuterator permuterator; | |
private Permuterator.Validator validator; | |
@Before | |
public void setUp() throws Exception { | |
permuterator = new Permuterator(); | |
validator = mock(Permuterator.Validator.class); | |
} |
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 Permuterator { | |
public void permute(List<String> values, int depth, Validator validator) { | |
values.parallelStream().forEach(value -> { | |
//add fist value | |
final String[] permutation = new String[depth]; | |
permutation[0] = value; | |
final int indexLimit = depth - 1; | |
traverse(permutation, values, indexLimit, 0, validator); |