Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Pro

ahmed.eltaher ahmedeltaher

💻
Pro
View GitHub Profile
View RemoteData.kt
package com.task.data.remote
import com.task.data.Resource
import com.task.data.dto.recipes.Recipes
import com.task.data.dto.recipes.RecipesItem
import com.task.data.error.NETWORK_ERROR
import com.task.data.error.NO_INTERNET_CONNECTION
import com.task.data.remote.service.RecipesService
import com.task.utils.NetworkConnectivity
import retrofit2.Response
@ahmedeltaher
ahmedeltaher / leetcode973.java
Created Oct 3, 2021
973. K Closest Points to Origin
View leetcode973.java
class Solution {
public int[][] kClosest(int[][] points, int k) {
int [][] res = new int[k][2];
PriorityQueue<int[]> maxHeap = new PriorityQueue<>(points.length,
new Comparator<int[]>(){
@Override
public int compare(int[] o1, int[]o2){
double d1 = distance(o1);
double d2 = distance(o2);
if(d1==d2) return 0;
@ahmedeltaher
ahmedeltaher / leecode215.java
Created Oct 3, 2021
215. Kth Largest Element in an Array
View leecode215.java
class Solution {
public int findKthLargest(int[] nums, int k) {
PriorityQueue<Integer> maxHeap = new PriorityQueue<>();
for(int num : nums){
maxHeap.add(num);
if(maxHeap.size()>k){
maxHeap.poll();
}
}
return maxHeap.poll();
@ahmedeltaher
ahmedeltaher / DataStructure.java
Last active Oct 25, 2021
DataStructure in Java
View DataStructure.java
package com.algoritms;
import org.junit.Test;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
View detekt-pre-commit
echo "Running detekt check..."
OUTPUT="/tmp/detekt-$(date +%s)"
./gradlew detekt > $OUTPUT
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
cat $OUTPUT
rm $OUTPUT
echo "***********************************************"
echo " Detekt failed "
echo " Please fix the above issues before committing "
View Kotlin Interview Questions.md

Interview Questions

Kotlin

Q1: What is a primary constructor in Kotlin? ☆☆

Answer: The primary constructor is part of the class header. Unlike Java, you don't need to declare a constructor in the body of the class. Here's an example:

View Kotlin Interview Questions.md

Interview Questions

Kotlin

Q1: What is a primary constructor in Kotlin? ☆☆

Answer: The primary constructor is part of the class header. Unlike Java, you don't need to declare a constructor in the body of the class. Here's an example:

View Paging.md
Core Elements in Paging library:
  • PagedList.
  • Data source.
PagedList:
  • collection.
  • loads data in pages.
  • Asynchronous data loading.
DataSource:
View data.json
[
{
"calories": "516 kcal",
"carbos": "47 g",
"description": "There\u2019s nothing like the simple things in life - the smell of freshly cut grass, sitting outside on a nice sunny day, spending time with friends and family. Well here is a recipe that delivers simple culinary pleasures - some nice fresh fish with a crispy crust, crunchy potato wedges and some delightfully sweet sugar snap peas flavoured with cooling mint. Slip into something comfortable and relax into a delicious dinner!",
"difficulty": 0,
"fats": "8 g",
"headline": "with Sweet Potato Wedges and Minted Snap Peas",
"id": "533143aaff604d567f8b4571",
"image": "https://img.hellofresh.com/f_auto,q_auto/hellofresh_s3/image/533143aaff604d567f8b4571.jpg",
View Horizontal VS Vertical Scaling.md
Horizontal Scaling Vertical Scaling
Load blancer Required N/A
Single point of failure resilient Yes, Suffering of a single point of failure
Communication Network-Calls (RPC) Internal process communication
Data Consistency No Yes
Scaling Scales well as users increasing HardWare limit