CnyrdSnyrd
BAN USERThe same logic can be easily extended to store num of paths at i,j. Path[i][j] = Path[i+1][j] + Path[i][j+1];
- CnyrdSnyrd February 17, 2013PATH array stores 1 if there exists a path from i,j to N,M using only rightward and downward directions else 0
Initialize PATH to all zeros.
PATH[N-1][M-1] = 1;
for i in N-1 to 0:
for j in M-1 to 0:
if(i<N-1):
PATH[i][j] = PATH[i+1][j];
if(j<M-1):
PATH[i][j] = PATH[i][j] | PATH[i][j+1];
PATH[i][j] = PATH[i][j] & bool[i][j];
check PATH[0][0];
Chrome stores everything in separate process, which implies that the parent process would keep a hashMap of all the process. The key would the index and value woud be the process. The process would provide the details with regard to tab-content. Movement of tabs is just swaping of hash-keys.
Each tab is a proces and have URL-Handler. The handler would call a factory of protocol, such as httpFactory, ftpFactory etc. Each protocol handler will call have a retrieving-engine and rendering-engine. The browser would retrieve and render using factory.
public class MyIterator<T>{
T[] arr;
int currPos;
int negPos;
int size;
public boolean hasNext(){
for(int i = currPos+1; i<size;i++){
if(arr[i] < 0){
if(negPos != i) negPos = i;
return true;
}
}
return false;
}
public T next(){
if(hasNext()){
currPos = negPos;
return a[currPos];
}
return null;
}
}
i think the question is talking about sequence not subsequence. Longest sequence can be calculated in O(n) time easily.
- CnyrdSnyrd February 04, 20143 4 6 is the correct ouput.