Which can never be the last day(s) of the century? You have to tell which of the seven day or days can never be the last of any century. You can consider 1 January 0001 to be a Monday for reference. After making a decent attempt yourself, scroll below for the answer. To answer … Continue reading Which can never be the last day(s) of the century?
What makes this question special is this tweet. https://twitter.com/mxcl/status/608682016205344768?lang=en He questions the interview process, I am with him. But whatever it is, it is. Question : Invert a binary tree. Return the root of the inverted tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 … Continue reading Invert a Binary Tree
Given two strings which represent different version releases of a software, print -1, 1 or 0 depending on the order of the releases. If version1 was released after version2 print 1, If version1 was released before version2 print -1, otherwise print 0. Assumptions granted : Strings may only contain digits and the '.'(dot) character … Continue reading Compare Versions
Question : Write a program that takes a 64-bit word, output the reverse of that word. I would urge you to minimize the window and try to solve this question on your own first. Method - 1 Brute Force Solution Simply apply the bitswap method we used earlier on all the extreme bits. Time … Continue reading 3. Reverse Bits
Question : Given a number and 2 indices return the number after swapping bits present at those indices. Method-1 : Brute-Force We can swap bits by following the given steps :- 1. Using bitmasks to extract the ith and jth bits. 2. Save the extracted bits to some local variables. 3. Write the jth bit to … Continue reading 2. Swap bits
Question : Compute the parity of a 64-bit word. Parity of a number refers to whether it contains an odd or an even number of 1's in its binary representation. The parity of a number is 1 if it contains odd number of 1's, else 0. Method-1 : Brute Force We can iteratively test the … Continue reading 1. Parity of a Word
I have decided to write complete solutions and analysis of the questions that are frequently asked in programming interviews at major tech. companies for the position of Software Engineer/Software Engineering Intern. This series will contain exhaustive list of solutions for all the problems posed in The Elements Of Programming Interviews, I will also maintain a Github … Continue reading A series on Programming Interview Questions