sunny
BAN USERint[] findLongestCommonSubsequense(int[] a){
Set<Integer> seen = new HashSet<Integer>();
Map<Integer, Integer> intervals = new HashMap<Integer, Integer>();
for(int j: a){
if(seen.contains(j)){
continue;
}
seen.add(j);
Int lo=j; hi=j;
for(int i=0; i<a.length; i++){
if(intervals.contains(i+1)){
hi = intervals.remove(i+1);
}
if(intervals.contains(i-1)){
lo = intervals.remove(i-1);
}
intervals.put(hi, lo);
intervals.put(lo,hi);
}
}
int hi=0, lo=0;
for(Entry<Integer, Integer> pair : intervals.entrySet()){
if(hi - lo < pair.getKey() - pair.getValue()){
lo = pair.getValue();
hi = pair.getPair();
}
}
Int ret[] = new int[hi-lo+1];
for(int i=0; i<ret.length; i++){
ret[i] = i + lo;
}
return ret;
}
int[] findLongestCommonSubsequense(int[] a){
Set<Integer> seen = new HashSet<Integer>();
Map<Integer, Integer> intervals = new HashMap<Integer, Integer>();
for(int j: a){
if(seen.contains(j)){
continue;
}
seen.add(j);
Int lo=j; hi=j;
for(int i=0; i<a.length; i++){
if(intervals.contains(i+1)){
hi = intervals.remove(i+1);
}
if(intervals.contains(i-1)){
lo = intervals.remove(i-1);
}
intervals.put(hi, lo);
intervals.put(lo,hi);
}
}
int hi=0, lo=0;
for(Entry<Integer, Integer> pair : intervals.entrySet()){
if(hi - lo < pair.getKey() - pair.getValue()){
lo = pair.getValue();
hi = pair.getPair();
}
}
Int ret[] = new int[hi-lo+1];
for(int i=0; i<ret.length; i++){
ret[i] = i + lo;
}
return ret;
}
boolean checkForUniqueStrings(String str){
boolean[] char_set = new boolean[128]; //if it is ASCII string.
for(int i=1; i<str.length()-1; i++){
int val = str.charAt(i);
if (char_set[val]){
return false;
}
return true;
}
}
//Time complexity is O(n); space complexity O(1).
RepJeanSwest, Data Engineer at Achieve Internet
I am a nuclear power reactor operator who is responsible for the flow of energy at a power plant. I ...
Repirmajrichh, Junior programmer at AppNexus
I am Irma, seeking the position of a Historical Researcher at Littler’s where my expertise can be utilized to ...
Repryanahurd, Korean Air Change Flight at 247quickbookshelp
Je suis Ryana avec 2 ans d'expérience dans la gestion d'un flux de travail à haut volume en ...
RepI am Risk managers that advise organizations on any potential risks to the profitability, safety, security or existence of the ...
Repjacksssones433, Apple Phone Number available 24/7 for our Customers at A9
Proficient and creative WordPress developer with a strong history in website management and development. Experienced in SEO and PPC campaign ...
RepGlennPCannon, Applications Developer at Techlogix
Hi everyone, I am a professor in Houston, USA. I like to explore new things about Hire Someone To Break ...
Repprishamondel, Quality Assurance Engineer at Bloomberg LP
I am Prisha, a versatile self-starter and a quick learner looking for a position within your company, Netaid. My hobbies ...
RepRobin has more than 26 years of experience working for state, city, university, and public entities as a fisheries ecologist ...
Reploragurrero, Research Scientist at Absolute Softech Ltd
I am Lora , an empathetic and dedicated Community Organizer with a deep passion for helping others and a strong determination ...
RepGarzaHodge, Backend Developer at Apache Design
I am Garza, and I work in many different research, education, and health care settings with varying roles, levels of ...
RepGiannaDavid, Author at The times
I am an Author, I have a passion for reading and creative writing and attend many workshops and conventions surrounding ...
- sunny July 31, 2017