StartUp Interview Question


Country: United States
Interview Type: Written Test




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

can you clarify the question a bit more?

- aka November 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Something in these lines:

var arr = ["aab", "bac", "aaa", "cda"];
    function wordChaining(arr){
     var index = 1;
        var arr = arr.sort();
        console.log(arr);
        var sortedArr = [arr[0]];
        var lastchar;
        while(index < arr.length){
            console.log("arr",arr[index].substring(0,1), arr, arr[index]);
            console.log("sorted",sortedArr[index-1].substring(arr[index-1].length-1), sortedArr, sortedArr[index-1])
         if(arr[index].substring(0,1)==sortedArr[index-1].substring(sortedArr[index-1].length-1)){
             sortedArr.push(arr[index]);
         }
            index++
        }
        return (sortedArr.length == arr.length) ? sortedArr : false;

    }
    console.log(wordChaining(arr))

- jsduder November 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is assuming that all characters are lowercase and ascii.

Create an int array of 26. Create a count int var. Loop through original string array, checking only the first and last letters. Add +1 to the int idex that corresponds with the ascii character code for both first and last letters. Before adding + 1 to character index if current int var is +1 to count, if current value is 1, -1. After looping through original string if count is greater than 0....the strings cannot make a circle. It 0, then they can.

- TheShocker1999 December 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Problem with your solution (TheShocker1999) is - as far as I see - is that there might be multiple circles. "aaa" and "bbb" would fulfil your conditions but it would be multiple circles... So you would have to check for that too

- Florian December 02, 2015 | Flag


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