Skip to content

Instantly share code, notes, and snippets.

View Magdi's full-sized avatar

Mohamed Magdi Magdi

View GitHub Profile
@Magdi
Magdi / build.gradle
Created March 30, 2017 11:05
gradle proguard multiple files
fileTree("${project.projectDir}/proguard").include('*.txt').files.each { file ->
proguardFile file
}
@Magdi
Magdi / ExampleApplication.java
Created March 10, 2017 18:12
leakcanary Application class
public class ExampleApplication extends Application {
@Override public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
@Magdi
Magdi / leakcanary.gradle
Created March 10, 2017 18:10
add leackcanary
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
}
public int[] productExceptSelf(int[] nums) {
int n = nums.length;
int[] left = new int[n], right = new int[n], arr = new int[n];
left[0] = 1;
right[n-1] = 1;
for (int i=1; i<n; i++) {
left[i] = left[i-1]*nums[i-1];
right[n-i-1] = right[n-i]*nums[n-i];
}
for (int i=0; i<n; i++)
public int[] productExceptSelf(int[] nums) {
int n = nums.length;
int[] pre = new int[n];
for(int i = 0 ; i < n ; i++){
pre[i] = (i == 0) ? 1 : pre[i-1] * nums[i - 1];
}
int post = 1 ;
int[] res = new int[n];
for(int i = n-1 ; i >= 0 ; i--){
ll dp(int mask, int rem, bool first) { // first for not using the first digit as zero
if (!mask) {
return rem ? 0 : 1;
}
ll &x = sv[mask][rem]; // memorization
if(x != -1)
return x;
x = 0;
int m = mask;
int used = 0;
#include <bits/stdc++.h>
#ifdef _MSC_VER
#include <hash_set>
#include <hash_map>
using namespace stdext;
#else
#include <ext/hash_set>
#include <ext/hash_map>
using namespace __gnu_cxx;