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 pro.programista.infrastructure.jpa; | |
import java.util.List; | |
import java.util.Optional; | |
import java.util.UUID; | |
import javax.persistence.EntityManager; | |
import org.springframework.data.domain.PageRequest; | |
import org.springframework.data.jpa.repository.support.SimpleJpaRepository; | |
import org.springframework.stereotype.Repository; | |
import pro.programista.domain.primitives.PageResult; |
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 { Observable, of, throwError } from "rxjs"; | |
import { concatMap, delay, retryWhen } from "rxjs/operators"; | |
import { Injectable } from "@angular/core"; | |
import { | |
HttpRequest, | |
HttpHandler, | |
HttpInterceptor, | |
HttpEvent | |
} from "@angular/common/http"; |
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 singleNumber(int[] nums) { | |
MultiValueMap<Integer, Integer> hash = new MultiValueMap<>(); | |
for (int index = 0; index < nums.length; ++index) | |
hash.put(nums[index], index); | |
for (int index = 0; index < nums.length; ++index) | |
if (hash.get(nums[index]).size() == 1) return nums[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 missingNumber(int[] nums) { | |
int[] hash = new int[nums.length + 1]; | |
for(int num : nums) // hashing the nums | |
++hash[num]; | |
for(int i = 0; i < hash.length; ++i) // finding the missing value | |
if(hash[i] == 0) return i; | |
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 void rotate(int[] nums, int k) { | |
int size = nums.length; | |
int[] rotated = new int[size]; | |
for(int index = 0; index < size; index++) { | |
rotated[(index + k) % size] = nums[index]; | |
} | |
for(int index = 0; index < size; index++) { | |
nums[index] = rotated[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 void rotate(int[] nums, int k) { | |
int size = nums.length; | |
int[] rotated = new int[size]; | |
for(int index = 0; index < size; index++) { | |
rotated[(index + k) % size] = nums[index]; | |
} | |
for(int index = 0; index < size; index++) { | |
nums[index] = rotated[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
/** | |
* Definition for a binary tree node. | |
* public class TreeNode { | |
* int val; | |
* TreeNode left; | |
* TreeNode right; | |
* TreeNode(int x) { val = x; } | |
* } | |
*/ | |
class Solution { |
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 { | |
private final int HASH_PRIME_FIRST = 54059; | |
private final int HASH_PRIME_SECOND = 76963; | |
int hashFunction(int key, int size) { | |
int hash = 37; | |
while(key > 0) { | |
hash += (hash * HASH_PRIME_FIRST) & (key * HASH_PRIME_SECOND); | |
key /= 10; |