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
{ | |
type: "FeatureCollection", | |
features: [ | |
{ | |
type: "Feature", | |
geometry: { | |
type: "Point", | |
coordinates: [ | |
-112.11971469843907, | |
33.36944420834164 |
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
var get_missing_letters = function (str) { | |
var alphabets = new Array(26); | |
var missing = []; | |
//initialize data | |
for (var j = 0; j < alphabets.length; j++) { | |
alphabets[j] = 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
public class RunLengthEncoding { | |
public static String LRE(String str){ | |
StringBuilder test = new StringBuilder(); | |
int count = 1; | |
char[] chars = str.toCharArray(); | |
for(int i=0;i<chars.length;i++){ | |
char c = chars[i]; |
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
#include<stdio.h> | |
int max(int, int); /* to get maximum of two integers */ | |
int min(int, int); /* to get minimum of two integeres */ | |
int median(int [], int); /* to get median of a sorted array */ | |
/* This function returns median of ar1[] and ar2[]. | |
Assumptions in this function: | |
Both ar1[] and ar2[] are sorted arrays | |
Both have n elements */ |
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
//method 1, works only for postive numbers | |
public class NonAdjacentMaximumSumSubsequence { | |
public static int NoAdjacentSum(int a[], int n) | |
{ | |
int[] dp =new int[n]; | |
dp[0] = a[0]; | |
dp[1] =a[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
/** | |
* | |
* Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements. | |
* @author paveynganpi | |
* | |
*/ | |
//reversal solution | |
/** | |
* |
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
public class getMedianOfTwoSortedArrays { | |
public static int getMedian(int ar1[], int ar2[], int n) | |
{ | |
int i = 0; /* Current index of i/p array ar1[] */ | |
int j = 0; /* Current index of i/p array ar2[] */ | |
int count; | |
int m1 = -1, m2 = -1; | |
/* Since there are 2n elements, median will be average |
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
public class MergeAnArrayOfSizeNIntoAnotherArrayOfSizeMPlusN { | |
static int NA=-1; | |
//move m elements to end of array | |
public static int[] moveToEnd(int[] mPlusN){ | |
int size = mPlusN.length; | |
int i = size-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
/** | |
* | |
* An element in a sorted array can be found in O(log n) time via | |
* binary search. But suppose I rotate the sorted array at some pivot | |
* unknown to you beforehand. So for instance, 1 2 3 4 5 might become | |
* 3 4 5 1 2. Devise a way to find an element in the rotated array in O(log n) time | |
* @author paveynganpi | |
* | |
*/ |
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 an array of positive integers. All numbers occur even number of | |
* times except one number which occurs odd number of times. Find the number | |
* in O(n) time & constant space. | |
Example: | |
I/P = [1, 2, 3, 2, 3, 1, 3] | |
O/P = 3 |
NewerOlder