Content Spoofing is the term used to define the type of attack by malicious programmers in which they present a fake website as a legitimate one to the user by text injection or html injection. When a web application does not properly handle the data supplied by the user using search etc. then the attacker can take advantage of such a situation and inject additional parameters that go unnoticed by the user. This leads to landing on another web page that looks the same as the original webpage. That page can ask the user to input information which is confidential ... Read More
Given a binary array arr[] and two variables a and b with some initial values. To cross an element in the array arr[] there are two ways −If arr[i] == 1, then 1 unit can be used from a, with no change in b. If 1 unit is used from b, then a increases by 1 unit. (Note that the value of a cannot be incremented above its original value.)If arr[i] == 0, then 1 unit can be used from a or b.Let’s now understand what we have to do using an example −Inputarr[] = {0, 0, 0, 1, 1}, ... Read More
Given the task is to find the maximum number of elements that can be made equal in a given array after incrementing its elements by at-most k times.Let’s now understand what we have to do using an example −Inputa[] = {1, 3, 8}, k = 4Output2ExplanationHere we can obtain two fours by incrementing 1 three times and incrementing 3 four times, that makes a[] = {4, 4, 8}Inputarr = {2, 5, 9}, k = 2Output0Approach used in the below program as followsIn main() function initialize int a[], size and k to store the array elements, size of array and the ... Read More
Given the task is to find the maximum number of distinct lower case alphabets that are present between two upper case alphabets in the given string.Let’s now understand what we have to do using an example −Inputstr = “JKyubDoorG”Output3Explanation“yub” is present between the two upper case alphabets K and D which makes the count 3.“oor” is also present between the two upper case alphabets D and G which makes the count 2 as ‘o’ is a repeating alphabet and we are looking for distinct alphabets.Therefore, the output is 3.Inputstr = “ABcefsTaRpaep”Output4Approach used in the below program as followsIn function Max() ... Read More
Given the task is to find a sub-string from a given binary string and then the maximum difference between the number of zeroes and the ones.Let’s now understand what we have to do using an example −Inputstr = “100100110”Output2ExplanationIn the sub-array from the position 1 to 5 (“00100”), the difference between the zeros and ones = 4 – 1 = 3 which is the maximum that can be found.Inputstr = “00000”Output5Approach used in the below program as followsIn main() function create a string str to store the binary string. Also initialize a variable int size to store the size of ... Read More
Given the task is to find a sub-string from a given binary string and then the maximum difference between the number of zeroes and the ones.Let’s now understand what we have to do using an example −Inputstr = “10010110”Output2ExplanationIn the sub-array from the position 1 to 4 (“0010”), the difference between the zeros and ones = 3 – 1 = 2 which is the maximum that can be found.Inputstr = “00000”Output5Approach used in the below program as followsIn main() function create a string str to store the binary string. Also declare an array int arr[str.length()+1];Set all elements of arr[] = ... Read More
Given the task is to find the maximum integer value that can be obtained while travelling in a path from the top left element to the bottom right element of a given square binary array, that is, starting from index [0][0] to index [n - 1][n - 1].While covering the path we can only move to right ([i][j + 1]) or to the bottom ([i + 1][j])The integer value will be calculate using the bits of the traversed path.Let’s now understand what we have to do using an example −Inputm = { {1, 1, 1, 1}, {0, 0, ... Read More
Given the task is to find the maximum count of substrings of length K consisting of same characters. Given a string s and another integer K, we have to count the occurrence of sub-strings of size K that have same characters.Out of the sub-strings that are found, we have to choose the sub-string occurring the maximum number of time.Let’s now understand what we have to do using an example −Inputs = ”tuuxyyuuc”, K = 2Output2ExplanationHere the sub-strings of length 2 and having same characters are: “uu” and “yy” but as it is seen that “yy” occurs only 1 time and ... Read More
Given the task is to find the maximum number of threads that can be created within a process in C.A thread is lightweight process and can be independently managed by the scheduler. Because a thread is a component of a process, therefore multiple number of threads can be associated in a process and also it takes less time for context switching as it is lighter than the process.Threads require less resources than the processes and they also share memory with its peer threads. All user level peer threads are treated as a single task by the operating system. Less time ... Read More
A Globally Unique Identifier or GUID represents a gigantic identification number — a number so large that it is mathematically guaranteed to be unique not only in a single system like a database, but across multiple systems or distributed applications.The total number of unique keys (3.40282366×1038) is so large that the probability of the same number being generated twice is very small. For an application using 10 billion random GUIDs, the probability of a coincidence is approximately 1 in a quintillion.(1030)For example, in Retail domain if we want to generate a unique for each transaction so that a customer can ... Read More