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.example.gk.np; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.Rect; | |
import android.graphics.Typeface; | |
import android.graphics.drawable.BitmapDrawable; |
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
--- a/node_modules/jest-haste-map/build/crawlers/node.js 2019-05-10 13:03:51.000000000 -0300 | |
+++ b/node_modules/jest-haste-map/build/crawlers/node.js 2019-05-10 13:10:49.000000000 -0300 | |
@@ -165,7 +165,7 @@ | |
} | |
function findNative(roots, extensions, ignore, callback) { | |
- const args = Array.from(roots); | |
+ const args = ['-L'].concat(Array.from(roots)); | |
args.push('-type', 'f'); | |
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
// Based on this problem: https://www.geeksforgeeks.org/auto-complete-feature-using-trie/ | |
// We are given a Trie with a set of strings stored in it. Now the user types in a prefix of his search query, we need to give him all recommendations to auto-complete his query based on the strings stored in the Trie. We assume that the Trie stores past searches by the users. | |
// For example if the Trie store {“abc”, “abcd”, “aa”, “abbbaba”} and the User types in “ab” then he must be shown {“abc”, “abcd”, “abbbaba”}. | |
function searchAutocomplete(head, prefix) { | |
const words = []; | |
if(!prefix) return words; | |
let currentNode = head; | |
for(let letter of prefix) { |
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
// Using BFS to solve | |
class Node { | |
constructor(data) { | |
this.data = data; | |
this.left = null; | |
this.right = null | |
} | |
} | |
function getBinaryTreeLevelsAverage(head) { |
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
// Given list of births and deaths find year with most people alive (in case of tie return any) | |
function maxPopulation(yearsOfBirthNDeath) { | |
const populationChange = []; | |
yearsOfBirthNDeath.forEach(([birth, death]) => { | |
if(populationChange[birth]) populationChange[birth] += 1; | |
else populationChange[birth] = 1; | |
const yearAfterDeath = death + 1; | |
if(populationChange[yearAfterDeath]) populationChange[yearAfterDeath] -= 1; | |
else populationChange[yearAfterDeath] = -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
// Using strategy of slower and faster pointers | |
class Node { | |
constructor(data) { | |
this.data = data; | |
this.next = null; | |
} | |
} | |
function hasCycle(head) { |
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
// Bucket Sort: O(N) method to sort natural numbers | |
function bucketSort(array) { | |
const buckets = []; | |
array.forEach(number => { | |
if(!buckets[number]) buckets[number] = 1; | |
else buckets[number] += 1; | |
}) | |
const sortedArray = []; | |
buckets.forEach((counter, number) => { |
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
function mergeSort(array) { | |
if(array.length <= 1) return array; | |
const half = Math.floor(array.length / 2); | |
const left = array.slice(0, half); | |
const right = array.slice(half); | |
const sortedLeft = mergeSort(left); | |
const sortedRight = mergeSort(right); | |
return merge(sortedLeft, sortedRight); |
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
function quickSort(array) { | |
if(array.length <= 1) return array; | |
const pivot = array[0]; | |
const [left, right] = pivotDivision(array.slice(1), pivot); | |
return [...quickSort(left), pivot, ...quickSort(right)]; | |
} | |
function pivotDivision(array, pivot) { | |
const left = []; |
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
function heapSort(array) { | |
const heap = heapify(array); | |
let lengthToConsider = array.length; | |
for(let i = array.length - 1; i > 0; i--) { | |
swap(array, i, 0); | |
lengthToConsider--; | |
descendHeap(array, lengthToConsider, 0); | |
} | |
} |
OlderNewer