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
<html> | |
<head> | |
<script src="https://www.gstatic.com/firebasejs/3.0.0/firebase.js"></script> | |
<title>ZeroToApp</title> | |
<style> | |
#messages { width: 40em; border: 1px solid grey; min-height: 20em; } | |
#messages img { max-width: 240px; max-height: 160px; display: block; } | |
#header { position: fixed; top: 0; background-color: white; } | |
.push { margin-bottom: 2em; } | |
@keyframes yellow-fade { 0% {background: #f2f2b8;} 100% {background: none;} } |
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 an unsorted array/list of n integers find the k-th largest element, where k <= n-1. | |
# Example: For A = [5,9,27,3,28,18,45] and k=4 the output will be 18. | |
def findKthLargestNumber(arr, n=3): | |
k= n-1 # | |
print(arr) # previous state | |
arr.sort(reverse=True) # {reverse=True} will make the sort to work in descending order | |
print(arr) # after sort in descending order | |
print(arr[k]) # fetch the kth value | |
findKthLargestNumber([5,9,27,3,28,18,45] ,4) |
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
info Starting JS server... | |
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)... | |
> Configure project :app | |
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) | |
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) | |
> Configure project :react-native-firebase | |
react-native-firebase: using React Native prebuilt binary from D:\React-Native\...\node_modules\react-native\android |
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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
ext { | |
googlePlayServicesVersion = "15.0.1" // default: "+" | |
firebaseVersion = "+" // default: "+" | |
buildToolsVersion = "28.0.3" | |
minSdkVersion = 16 | |
compileSdkVersion = 28 | |
targetSdkVersion = 28 |
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
// Input: [[1,3],[2,6],[8,10],[15,18]]; | |
// Output: [[1,6],[8,10],[15,18]]; | |
// Explaination: Since intervals [1,3] and [2, 6] overlaps, merge them into [1, 6]. | |
var arr = [[1,3],[2,6],[8,10],[15,18]]; | |
var newArr = []; | |
var index = 0; | |
while (index <= arr.length-1) { | |
var currentVal = arr[index]; | |
var nextVal = arr[index+1] || 0; |
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
// codility test prep questions | |
// For example, number 9 has binary representation 1001 and contains a binary gap of length 2. | |
// The number 529 has binary representation 1000010001 and contains two binary gaps: one of length | |
// 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. | |
// The number 15 has binary representation 1111 and has no binary gaps. The number 32 has binary representation | |
// 100000 and has no binary gaps. | |
function findFirstNumberOfZeroes(num){ | |
var binary = num.toString(2); | |
var numberOfZeros = 0; |
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
// codility test prep questions | |
// For example, in array A such that: | |
// A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9 | |
// the elements at indexes 0, 2 and 4 have value 9, | |
// the elements at indexes 1 and 3 have value 3, | |
// the element at index 5 has value 7 and is unpaired. | |
function findPairs(arr){ | |
var hash = {} | |
arr.map((num)=>{ |
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
// codility test prep questions | |
// A small frog wants to get to the other side of the road. The frog is currently located at position X | |
// and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. | |
// Count the minimal number of jumps that the small frog must perform to reach its target. | |
// Given X = 10, Y = 85, D = 30 | |
// the function should return 3 | |
function numberOfFrogJumps(x,y,d){ | |
var distanceRequired = y-x; | |
var jumps = Math.ceil(distanceRequired/30) |