Skip to content

Instantly share code, notes, and snippets.

View praveenKajla's full-sized avatar
😍
go

Praveen k. praveenKajla

😍
go
  • loco
  • Jaipur, India
View GitHub Profile

This Documentation is recieved as an artifact of utmost importance from the desert of the dead.

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.

//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)
}
@praveenKajla
praveenKajla / algo.md
Last active October 21, 2017 09:37
Given an array of integers, sort the array according to frequency of elements.

-- 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

@praveenKajla
praveenKajla / minHeap.js
Created October 20, 2017 12:44
Minimum heap in Javascript => es6
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
@praveenKajla
praveenKajla / equal0and1Subarray.js
Created October 20, 2017 08:50
Largest subarray with equal number of 0s and 1s => es6
//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++){
@praveenKajla
praveenKajla / AVLTree.js
Created October 17, 2017 19:27
AVLTree in ES6
class Node{
constructor(d){
this.key = d;
this.height = 1
this.left = null
this.right = null
}
}
@praveenKajla
praveenKajla / leftArrayRotate.js
Last active October 15, 2017 07:04
Write a function rotate(ar[], d, n) that rotates arr[] of size n by d element
//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 = []
"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;
}
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(){}