Amazon Interview Question for SDE1s


Country: United States
Interview Type: Phone Interview




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

public static List<String> logProcessor (List<String> list){
        List<String> strAlp = new ArrayList<String>();
        List<String> strNum = new ArrayList<String>();
        List<String> AlpNum = new ArrayList<String>();

        for( String sl :  list){
            String[] slPart = sl.split(" ", 2);
            if(Character.isDigit(slPart[1].charAt(0))){
                strNum.add(sl);
            }
            else {
                strAlp.add(slPart[1].concat(" " + slPart[0]));
            }
        }
        Collections.sort(strAlp);
        for(String sl2 : strAlp){
            String[] part = {sl2.substring(0,sl2.lastIndexOf(" ")), sl2.substring(sl2.lastIndexOf(" ") + 1)};
            AlpNum.add(part[1].concat(" " + part[0]));
        }
        AlpNum.addAll(strNum);
        return AlpNum;
    }

- Bukary Kandeh May 30, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public List<string> SortFile(int size, List<string> logFile) {
            //assumption: The input to the function / method always consists of two arguments
            return  ((from log in logFile
                     where !Char.IsDigit((log.Split(" ".ToCharArray(), 2)[1].Trim())[0])
                     orderby log.Split(" ".ToCharArray(), 2)[1].Trim()
                     select log)
                     .Union
                     (from log in logFile
                        where Char.IsDigit((log.Split(" ".ToCharArray(), 2)[1].Trim())[0])
                        orderby log.Split(" ".ToCharArray(), 2)[1].Trim() descending
                        select log))
                     .ToList();

}

- alir2t2 June 11, 2018 | 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