## Posts

### Coding Interview Questions Set 3 ### Css Interview Questions Set 1 Let's begin with set 1, 1)What is CSS box model? The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content. The image below illustrates the box model: Explanation: Content - The content of the box, where text and images appear. Padding - Clears an area around the content. The padding is transparent Border - A border that goes around the padding and content. Margin - Clears an area outside the border. The margin is transparent. 2)What are selectors in CSS? In CSS, selectors are patterns used to select the elements you want to style. Here are few most used selectors, a).class : Ex:.intro Selects all elements with class="intro". b).class1.class2 Ex: .name1.name2 Selects all elements with both name1 and name2 set within its class attribute. c)#id  Ex:#firstname Selects the element with id="firstname". d)element  Ex:p Selects all <p> ele

### Coding Interview Questions Set 2 For first 3 questions and answers please refer to   Coding Interview Questions Set 1 . Let's begin with set 2, 4)For a given binary tree find the depth/height of a binary tree. Solution : var depth= function(root) {     if(root === undefined || root===null){         return 0;     }     return Math.max(depth(root.left),depth(root.right)) + 1; }; Logic: Divide and conquer. 5)In a given array move all the 0 's to the end without disturbing order of non-zero elements.  Solution: var moveZeroes = function(nums) {          for(var i = nums.length;i--;){         if(nums[i]===0){             nums.splice(i,1)             nums.push(0);         }     } }; Logic: Remove each 0 and add 0 at the end of the array. 6)Calculate the sum of 2 integers without using + and - operator. Solution: var add = function(a, b) {     let carry;     while(b) {         carry = a & b;         a ^= b;         b = carry << 1;     }     return a; }; Logic:

### Coding Interview Questions Set 1 From this article, I will be sharing with you all a series of articles on coding interview questions. So please stay connected for the latest set of questions. It will be a good brainstorming exercise and will also prepare you for coding interviews and will definitely boost your confidence. So let's start, 1)Reverse of a string with only O(1) extra memory. Solution: var reverse = function(string) {     let result = ''     for(let i= string.length -1; i >= 0; i--){         result += string[i];     }     return result; }; 2)Fizz Buzz: Write a program that will accept a number n and will output number till n but for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Solution: var fizzBuzz= function(n) {     const arr=[]     for(i=1; i<=n; i++){         if(i%15===0) arr.push("FizzBuzz")         else   