munir1690
BAN USERpublic int[] productExceptSelf(int[] nums) {
if(nums.length == 0){
return new int[0];
}
int[] result = new int[nums.length];
result[0]=1;
for(int i=1;i<nums.length;i++){
result[i]=result[i-1]*nums[i-1];
}
int product = 1;
for(int i=nums.length-1;i>=0;i--){
result[i]=result[i]*product;
product = product*nums[i];
}
return result;
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author dell
*/
public class Main2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new Main2().substringCombination("", 3, 0);
}
public void substringCombination(String prefix, int n, int k) {
if (n == 0) {
System.out.println(prefix);
return;
}
for (int i = k+1; i <=9; i++) {
substringCombination(prefix +i , n-1,i);
}
}
}
Do you think taking 10k Long number and setting bits every time would work ?
- munir1690 October 09, 20161billion/10k*64bits(unsigned long bits) ~=1562 times algorithm would have to run and we can get the missing numbers.
Just look for numbers 1-64000 and set the bits accordingly in 1-10000 numbers.
keep on increasing range.
Not sure though if this is best solution, something on top of my head.