aileen
BAN USERstatic void findLongestSubstring(String target)
{
if(target==null || target.length()==0) return ;
char first=target.charAt(0);
char second='\0';
int maxLength=0;
String maxString="";
int start1=0;
int start2=0;
for(int i=0; i<target.length(); i++)
{
if(second=='\0')
{
if(target.charAt(i)!=first)
{
second=target.charAt(i);
start2=i;
}
}else
{
if(target.charAt(i)!=first && target.charAt(i)!=second)
{
int minValue=Math.min(start1 , start2);
if(i-minValue>maxLength)
{
maxLength= i-minValue;
maxString=target.substring(minValue, i);
}
if(start1<start2)
{
start1=i;
first=target.charAt(i);
}else
{
start2=i;
second=target.charAt(i);
}
}
}
}
System.out.println(maxString);
}
Time: O(n)
Space:O(1)
select e.empid, e.empname, T.yearR, T.monthR, T.salary
from guol.emp e left join
(
select h.empid as eid, extract(year from t.dateE) as yearR, extract(month from t.dateE) as monthR, sum(t.no_of_hours*h.rate) as salary
from guol.emp_h h, guol.emp_t t
where h.empid=t.empid
group by h.empid, extract(year from t.dateE), extract(month from t.dateE) ) T on e.empid=T.eid
;
good solution. Additionally,
- aileen June 13, 2013We can use stack to get the more array and the less array. It will increase the speed.