Suppose we have a string, password. We have to find out minimum changes required to make the password strong. So the password has some following criteria −It must be at least 6 character long and at most 20-character longIt must contain at least one lowercase letter, at least one uppercase letter, and at least one numeric character.It must not contain three repeating characters in a row like …aaa…, …PPP…, …888….So if the input is like "aa26bbb", so we need at least one change, as there is no uppercase letter, and there is three b’s in a row, so we can ... Read More
You can tell your browser not to cache your page by using the following meta tags − In addition, try the following: Append a parameter/string to the filename in the script tag. Change it when the file changes.Then the next time you update the file, just update the version i.e.
Suppose we have an array of positive integers and one value m. We can divide this array into m number of contiguous subarrays. We have to devise an algorithm to minimize the largest sum among these m subarrays.So if the array is say [7, 2, 4, 10, 9], and m = 2, then the sum will be 19, as we can make two subarrays like [7, 2, 4] and [10, 9], then the subarray with largest sum is 19.To solve this, we will follow these steps −Define a function splitArray(), this will take an array v, m, n := size ... Read More
Suppose there is a frog that is crossing a river. The river is divided into x units and at each unit there may be a stone. The frog can jump on a stone, but not water. Here we have a list of stones' positions in sorted ascending order sequence, we have to check whether the frog is able to cross the river by landing on the last stone, or not. Initially, the frog is on the first stone and assume the first jump must be of 1 unit.When the frog's current jump was k units, then its next jump must ... Read More
Suppose, we want to make a data structure, that supports some operations, these operations must be preformed in O(1) amount of time. So let these operations are like −insert(x): insert x into the collectionremove(x): delete x from the collectiongetRandom(): This will find random element form that collection.To solve this, we will follow these steps −Make an array numsmake one map mDefine a function insert(), this will take val, ret := when val is not in minsert size of nums at the end of m[val]insert { val, size of m[val] – 1} pair at the end of numsreturn retDefine a function ... Read More
Add the following code snippet to image properties, and prevent images from being dragged and selected.img { user-drag: none; user-select: none; -moz-user-select: none; -webkit-user-drag: none; -webkit-user-select: none; -ms-user-select: none; }On double click on a text or image, it is highlighted (selected). The user select property can be used to prevent this. By setting this property to none, we can prevent our image from being selected (highlighted).ExampleYou can try to run the following code to prevent the image from being selected − img { -drag: none; user-select: none; -moz-user-select: none; -webkit-user-drag: none; -webkit-user-select: none; -ms-user-select: none; }
The refresh button which was until now hidden in the flow menu, has been replaced by pull-down-to-refresh feature in chrome. However, some users do not need this feature in their application.body { // disables pull-to-refresh // allows overscroll glow effects overscroll-behavior-y: contain; }The overscroll behaviour property of CSS disables the pull to refresh action. In the above given code we have fixed double pull to refresh animation in the chatbox demo. The inbox blurs while the entire page is being refreshed.
Suppose we have a 2D matrix, and an integer k. We have to find the max sum of a rectangle in the matrix, such that its sum is not greater than k. So, if the input is like −1010-32And k = 3, then the output will be 3, as the sum of marked rectangle is 3.To solve this, we will follow these steps −Define a function maxSumSubmatrix(), this will take one 2D array matrix and k, n := row number, m := column numberans := -inffor initialize l := 0, when l < m, update (increase l by 1), do ... Read More
Use the onfocus attribute to execute a script when the element gets focus in HTML.ExampleYou can try to run the following code to implement the onfocus attribute − Enter subject name below, Subject: function display(val) { document.getElementById(val).style.background = "blue"; }
Suppose we have some envelops, these envelops has height and width values as pairs. We can put one envelop into another one if the height and width of second envelop both are smaller than the height and width of the first one. So, what will be the maximum number of envelops that we can put inside other. So, if the inputs are like [[5, 5], [6, 4], [6, 8], [2, 3]], then the output will be 3, as smallest envelop is [2, 3], then [5, 5], then [6, 8].To solve this, we will follow these steps −sort the array v ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP