The third question was pretty difficult as per me.
Anonymous
Answer 1) Calculate length . Divide the 2 and parse the limit till then the middle. Pass the middle element to the linked list reverse . Need to reverse the list from the middle + 1 element. And then from the start and middle+1 compare each other to find whether palindrome or not. And finally revert back the list to original order. This was the logic I could come up with . I did mistake in the reverse logic I passed middle + 1 directly instead of middle. Answer 2) Take another array which would store frequencies. Start i = 0 to (n-1). First take 1 element and fill it and calculate its freq in the new array j= 0 to i; Now nth element for i would have to parse j = 0 to i And see if the val matches the a[i] and increment the freq array. And then calculate the max freq each time from j = 0 to i . Answer 3) I couldn't answer this I knew it had to recursion. Now given the binary tree we can form lot of trees . But all combinations would be root node would be element 1 to n (for n nodes). So basically find the least weight for each root node element tree and then find the minimum every time. This still I need to try.
Check out your Company Bowl for anonymous work chats.