Humanity is almost dead and machines rule the world and they grow humans and use them as a source for their power.
But don't lose the hope.
Our Hero Neo is alive and is here to help you.
Neo in collabration with Morpheus have built two applications
/ ...
/
/
Kliento Leseva
to keep the humans of planet pocket aces free from any rival machines and to come up with new ideas.
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
//Write a function to get the intersection point of two Linked Lists. | |
function intersection(ll1,ll2){ | |
let c1 = ll1.length() | |
let c2 = ll2.length() | |
let d = Math.abs(c1-c2) | |
if(c1>c2){ | |
return getIntersection(d,ll1.head,ll2.head) | |
}else{ | |
return getIntersection(d,ll2.head,ll1.head) | |
} |
-- create BST with freq property updated if duplicate is inserted
-- do inorder traversal and store the data and freq of each node in an auxiliary array count => [{data:data,freq:freq}]
-- sort the count array with descending frequency
-- traverse the array and print every data element in count count[i].freq times
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 minHeap{ | |
constructor(capacity){ | |
this.heapSize = -1; | |
this.heap = Array(capacity).fill(-1) | |
} | |
insert(value){ | |
if(this.heapSize+1==this.heap.length){ | |
throw "Overflow Size" | |
} | |
this.heap[this.heapSize+1] = value |
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
//Largest subarray with equal number of 0s and 1s// | |
//Pass 1 | |
var assert = require('assert') | |
function pass1(arr=[]){ | |
let n = arr.length,maxLength = -1,sum=0,start | |
for(let i=0;i<n-1;i++){ | |
sum = (arr[i]==0) ? -1 : 1 | |
for(let j=i+1;j<n;j++){ |
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 Node{ | |
constructor(d){ | |
this.key = d; | |
this.height = 1 | |
this.left = null | |
this.right = null | |
} | |
} |
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
//Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements | |
//https://www.youtube.com/watch?v=utE_1ppU5DY | |
//pass 1 | |
//1.copy first d elements in temp array | |
//2.move original array forward by d | |
//3.start updating vlues in originl array from n-d th position | |
// time complexity n space complexity d | |
function rotate1(arr=[],d){ | |
let n = arr.length | |
let temp = [] |
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
"use strict"; | |
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } | |
var log = console.log; | |
function example(a, b, c) { | |
log({ a: a, b: b, c: c }); | |
return a * b * c; | |
} |
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 Log(){ | |
companion object Factory{ | |
@JvmStatic fun createFileLog(filename: String):Log = Log(filename) | |
//we can access this static function from java using @JvmStatic as Log.createFileLog("File.txt") | |
} | |
//second companion object not possible | |
constructor(filename:String):this(){} |
NewerOlder