Monotonically Increasing String:A string of '0's and '1's is monotonically increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.)ProblemWe are required to write a JavaScript function that takes in a binary string, str, as the first and the only argument.We can flip any ‘0’ to ‘1’ or any ‘1’ to ‘0’ present in the string. Our function should return the minimum number of flips to make S monotonically increasing.For example, if the input to the function isInputconst str = '00110';Outputconst output = 1;Output ExplanationBecause if we flip the last ... Read More
ProblemWe are required to write a JavaScript function that takes in a binary array, arr, as the first argument, and a number, target, as the second argument.Our function is supposed to count the number of subarrays that exists in the array arr, the sum of whose elements is equal to count. We should finally return this count.For example, if the input to the function isInputconst arr = [1, 0, 1, 0, 1]; const target = 2;Outputconst output = 4;Output ExplanationBecause the desired subarrays are:[1, 0, 1][1, 0, 1, 0] [0, 1, 0, 1] [1, 0, 1]Example Live Democonst arr = [1, ... Read More
In this post, we will understand the difference between RGB and CMYK colour schemes −RGB Colour SchemeIt is used with digital works.The primary colours in this scheme are ‘Red’, ‘Green’, and ‘Blue’.It is an additive Type Mixing scheme.The colours of this scheme’s images are more vibrant.It has a wide range of colours in comparison to CMYKThe file formats to work with this colour scheme are JPEG, PNG, and GIF.CMYK Colour SchemeIt is used with print works.The primary colours in this scheme are ‘Cyan’, ‘Magenta’, ‘Yellow’, and ‘Black’.It is a subtractive Type Mixing scheme.The colours of this scheme’s images are less ... Read More
In this post, we will understand the difference between USART and UART modes −USART (Universal Synchronous/Asynchronous Receiver/Transmitter)The half-duplex mode is used.The speed of USART is more in comparison to UART.It uses data signals as well as clock to work.The data is transmitted in the format of blocks.It can work similar to UART.It is more complex in comparison to UART.The receiver doesn’t require to know the baud-pace of the transmitter.This is because it gets information by the master and the clock signal.The data is transmitted at a definite (specific) rate.UART (Universal Asynchronous Receiver/Transmitter)It uses full-duplex mode.Its speed is less in comparison ... Read More
In this post, we will understand the difference between cache and cookies −CacheIt helps store the content of the website which is used frequently.The content of the website is stored in the browser.It expires manually.It consumes more space.Different types of cache are: Browser cache and proxy cache.It stores contents like HTML pages, images, JavaScript, CSS.It doesn’t send a response with a request.CookiesIt helps store the user’s choice.The contents of the cookie are stored in both the server and browser.It expires automatically.It consumes less space.Different types of cookies are: Transient cookies and persistent cookies.A cookie stores the contents such as browsing ... Read More
In this post, we will understand the difference between wordpress.com and wordpress.org −Wordpress.orgIt is also known as the real WordPress.It is open source, and can be used by anyone.A domain name and a web hosting service is required to use this.It is also referred to as self-hosted WordPress.User has full control of the website.WordPress plugins that are free, or paid can be added to the website.The website and all of its data is owned by the user.Google analytics can be used to perform customized analytics.Advertisements can be run and revenue can be generated.User has to keep several backups of the ... Read More
ProblemWe are required to write a JavaScript function that takes in a string of English alphabets, str, as the first and the only argument. Our function should return true if and only if the vowels and consonants appear alternatingly in the input string, false otherwise.For example, if the input to the function is −Inputconst str = 'amazon';Outputconst output = true;Output ExplanationBecause the vowels and consonants appear alternatingly in the string ‘amazon’.ExampleFollowing is the code − Live Democonst str = 'amazon'; const appearAlternatingly = (str = '') => { return str.split('').every((v, i)=>{ if (/[aeiou]/.test(str[0])){ ... Read More
ProblemWe are required to write a JavaScript function that takes in two arrays of numbers, arr1 and arr2, as the first and second argument respectively.Our function should return true if and only if every element in arr2 is the square of any element of arr1 irrespective of their order of appearance.For example, if the input to the function is −Inputconst arr1 = [4, 1, 8, 5, 9]; const arr2 = [81, 1, 25, 16, 64];Outputconst output = true;ExampleFollowing is the code − Live Democonst arr1 = [4, 1, 8, 5, 9]; const arr2 = [81, 1, 25, 16, 64]; const isSquared ... Read More
ProblemWe are required to write a JavaScript function that takes in any number of arrays of literals as input.Our function should prepare a new array that contains elements picked alternatingly from all the input arrays.For example, if the input to the function is −Inputconst arr1 = [1, 2, 3, 4]; const arr2 = [11, 12, 13, 14]; const arr3 = ['a', 'b', 'c'];Outputconst output = [1, 11, 'a', 2, 12, 'b', 3, 13, 'c', 4, 14];ExampleFollowing is the code − Live Democonst arr1 = [1, 2, 3, 4]; const arr2 = [11, 12, 13, 14]; const arr3 = ['a', 'b', 'c']; ... Read More
ProblemWe are required to write a JavaScript function that takes in a string, str, that contains alphabets and whitespacesOur function should iterate over the input string and perform actions so that the characters are concatenated into a new string in "case-insensitively-alphabetical-order-of-appearance" order. Whitespace and punctuation shall simply be removed!For example, if the input to the function is −Inputconst str = 'some simple letter combination!';Outputconst output = 'abceeeeiiillmmmnnoooprssttt';ExampleFollowing is the code − Live Democonst str = 'some simple letter combination!'; const orderString = (str = '') => { let res = ''; for(let i = 97; i < ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP