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
import UIKit | |
// Runnable -> no input, no output | |
// Callable -> no input -> Producer | |
// Function -> input, output | |
// Consumer | |
// **Higher order function** |
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
import java.util.Arrays; | |
import java.util.List; | |
// Uber $ - 5 3 4 6 7 8 9 9 7 6 5 8 | |
// Any day - You can buy 1 stock or you can sell all your stocks or do nothing. | |
// You have to maximize your profit. | |
// (9-5) + (9-3) + (9-4) + (9-6) + (9-7) + (8-7) + (8-6) + (8-5) | |
// 8, 5, 6, 7, 9, 9, 8 | |
// max = 9 | |
public class StockBuySell { |
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 BalancedParanthesis2 { | |
public static void main(String[] args) { | |
} | |
// ((())) | |
private static boolean validExpression(String expression, int numOfRetriesAvailable) { | |
if (expression == null) { | |
return true; | |
} |
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 Arbit { | |
public static void main(String[] args) { | |
Arbit arbit = new Arbit(); | |
Container container = new Container(); | |
container.a = 7; | |
container.b = 6; | |
arbit.change(container); | |
int d = 5; | |
arbit.changeInt(d); | |
System.out.println(container); |
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 InsertionSort { | |
public int[] sort(int[] input) { | |
int[] output = new int[input.length]; | |
for (int i=0; i<input.length; i++) { | |
int indexToInsert = 0; | |
for (int j=0; j<=i; j++) { | |
if (input[i] < output[j]) { | |
indexToInsert=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
// Given a sorted linked list, delete all duplicates such that each element appear only once. | |
// For example, | |
// Given 1->1->2, return 1->2. | |
// Given 1->1->2->3->3, return 1->2->3. | |
/** | |
* Definition for singly-linked list. | |
* class ListNode { | |
* public int val; |
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 with n objects colored red, white or blue, | |
// sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. | |
// Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. | |
// Note: Using library sort function is not allowed. | |
// Example : | |
// Input : [0 1 2 0 1 2] |
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
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import javax.annotation.Nonnull; | |
import javax.annotation.Nullable; | |
public class EmailDummy { | |
@Nonnull | |
public final String From; |
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
// GC is a background thread and JVM doesn't have a spec for it to be daemon or not. | |
// https://stackoverflow.com/questions/5553783/java-garbage-collection-thread-priority | |
public class WeakReferenceCaller { | |
public static void main(String[] args) throws InterruptedException { | |
MyObject myObject = new MyObject(); | |
Thread thread = new Thread(new WeakReferenceRunnable(myObject)); | |
thread.start(); | |
myObject = null; | |
System.out.println(myObject); |
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
import android.animation.Animator; | |
import android.animation.AnimatorListenerAdapter; | |
import android.view.View; | |
import com.example.harshitbangar.ribswithoutdagger.ScreenStackImpl; | |
import static android.view.View.GONE; | |
import static android.view.View.VISIBLE; | |
public class CrossfadeTransition implements Transition { |
NewerOlder