Intuit Interview Question for Senior Software Development Engineers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 1 vote

public class LongToDate {
    public static void main(String args[]){
        long to = System.currentTimeMillis();
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/YY");
        System.out.println((formatter.format(new Date(to))));
    }
}

- venkat2023 October 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Note 2 - Should not use any pre-defined methods or any pre-defined classes like Calendar/Date/DateFormat etc. in java

- sambasivareddy.s October 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Non trivial code. Absolutely non trivial. Here is one part of it, when the dates are larger than 1970 Jan 01 :

MS_IN_NORMAL_YEAR = 365 * 24* 60 * 60 * 1000 
MS_IN_LEAP_YEAR = 366 * 24 * 60 * 60 * 1000 
DAYS_IN_MONTH = [ 0, 31, 28 , 31, 30, 31, 30, 31, 31, 30, 31 , 30, 31 ]

def is_leap_year( year ){
  return ( ( 400 /? year ) || ( !( 100 /? year ) && ( 4 /? year ) ) )
}
def get_ms_in_month( month, is_leap ){
  if ( is_leap && month == 2 ) return 29 * 24 * 60 * 60 * 1000 
  return DAYS_IN_MONTH[month] * 24 * 60 * 60 * 1000 
}

def date( millisec ){
   year = 1970 // *nix inception year 
   is_leap = is_leap_year( year )
   ms_in_year = ( is_leap ? MS_IN_LEAP_YEAR : MS_IN_NORMAL_YEAR )
   while ( millisec > ms_in_year ){
      millisec -= ms_in_year 
      year +=1
      is_leap = is_leap_year( year ) 
      ms_in_year = ( is_leap ? MS_IN_LEAP_YEAR : MS_IN_NORMAL_YEAR )
   }
   println ( year )
   // at this point, we have found the years, now add months 
   month = 1
   ms_in_month = get_ms_in_month ( month, is_leap )
   while ( millisec > ms_in_month ){
     millisec -= ms_in_month
     month +=1
     ms_in_month = get_ms_in_month ( month, is_leap )
   }
   days = (millisec / ( 24 * 60 * 60 * 1000 ))  + 1 
   [ days, month, year ]
}

res = date ( 1476615214741  )
println( res )

- NoOne October 16, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More