Skip to content

Instantly share code, notes, and snippets.

View vsvankhede's full-sized avatar
🎯

Vijay Vankhede vsvankhede

🎯
View GitHub Profile
public class TwoPolitician {
public static class Pair {
String follower;
String following;
public Pair(String follower, String following) {
this.follower = follower;
this.following = following;
}
}
/**
* Bubble sort algorithm.
* Time complexity: O(n*n)
* Space complexity: O(1)
*/
static int[] bubbleSort(int[] A) {
for (int i = 0; i < A.length; i++) {
for (int j = 0; j < A.length - 1 ; j++) {
if (A[j] > A[j + 1]) {
int temp = A[j + 1];
/**
* Find element position in sorted int array using binary search.
* Time- O(long n) Space- C
*/
static int binSearch(int[] A, int k) {
int l = 0;
int u = A.length - 1;
int m;
while (l <= u) {
@vsvankhede
vsvankhede / DemoActivityLoader.java
Created August 7, 2016 11:07
Demo Activity implements loader callback.
public class DemoActivity extends Activity implements LoaderManager.LoaderCallbacks<T> {
private static final int LOADER_ID = 1;
public void onCreate(Bundle savedInstanceState) {
getLoaderManager().initLoader()
}
public Loader<T> onCreateLoader(Loader<T> loader, T data) {
// Create the loader
}
dependencies {
compile 'com.parse.bolts:bolts-tasks:1.3.0'
paidCompile 'com.android.support:design:23.1.1'
freeCompile 'com.parse:parse-android:1.12.0'
}
android.variantFilter { variant ->
if(variant.buildType.name.equals('release')
&& variant.getFlavors().get(0).name.equals('mock')) {
variant.setIgnore(true);
}
}
@vsvankhede
vsvankhede / build.gradle
Last active July 3, 2016 14:45
Define product flavours
productFlavors {
free {
}
paid {
}
}
@vsvankhede
vsvankhede / build.gradle
Last active July 3, 2016 13:11
Sample of using productFlavours.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.pf"
minSdkVersion 15
targetSdkVersion 23
import android.os.Parcel;
import android.os.Parcelable;
/**
* Parcelable Doa class. To pass onject from one activity to another
* via Intent
*/
public class DaoClass implements Parcelable {
String data1;
String data2;