This is a classical interview question in which you are asked to find the location of the rightmost and the leftmost 1's in the binary representation of a number. I. Rightmost Set Bit & Rightmost Bit Here we compute the AND between the original number (say N) with its two's complement (its negative form). Thus,… Continue reading BLOG | Find the rightmost & leftmost set bit of an integer
Category: Practice
BLOG | Split an array into k subarrays
Hint: Binary search is mostly used for this kind of questions. The simplest form of this question would be finding pivot element, which requires you to find an index in an array that makes the sum of all elements to its left equals to the sum of all elements to its right. Leetcode 724: Find… Continue reading BLOG | Split an array into k subarrays
BLOG | Inverted index: search keywords in a list of documents
Given a list of documents and a list of keywords, how do we find all documents containing one or multiple keywords? For this question, we tokenize all documents into terms, and create a inverted index where each term is associated with a list of documents that contains that term. We use this information to rank… Continue reading BLOG | Inverted index: search keywords in a list of documents



