Here we will see one C puzzle question. Suppose we have two numbers 48 and 96. We have to add the first number after the second one. So final result will be like 9648. But we cannot use any logical, arithmetic, string related operations, also cannot use any pre-defined functions. So how can we do that?This is easy. We can do by using Token Pasting operator(##) in C. The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro definition.Example#include #define MERGE(x, ... Read More
Here we will see the quicksort technique but we will use three-way quicksort. The basic quicksort technique is just finding an element as pivot then partition the array around pivot, after that, recur for sub arrays on left and right of the pivot.The three-way quicksort is similar, but there are three sections. array arr[1 to n] is divided into three parts.arr[1 to i]arr[i + 1, j]arr[j + 1, n]Algorithmpartition(arr, left, right, i, j) −begin if right – left
The HTML DOM Storage removeItem() method is used for removing a storage object item by passing a given key name.SyntaxFollowing is the syntax for Storage removeItem() method −localStorage.removeItem(keyname);ORsessionStorage.removeItem(keyname);Here, keyname is of type string and represents the name of the item to be removed.ExampleLet us look at the example for the Storage removeItem() method − Storage removeItem() method example Delete the localstorage item by clicking the below button DISPLAY localStorage.setItem("TEXT1", "HELLO WORLD"); function itemDelete() { localStorage.removeItem("TEXT1"); itemShow(); } function itemShow() { var x = ... Read More
The HTML DOM Storage key() method is used for returning the key name at a given index in a storage object. The index is passed as a parameter to key() method. The storage object can be a session object or localStorage object.SyntaxFollowing is the syntax for −Storage key() method using localStorage −localStorage.key(index);Storage key() method using sessionStorage −sessionStorage.key(index);Here, index is of type integer representing the key number that you want to get the name for.ExampleLet us look at the example for the Storage key() method − storage key() method example Get the first object key name by clicking on ... Read More
The HTML DOM storage event triggers when there has been a change in the storage area of the window. The storage event is triggered only if the other window makes the storage area change for a window. This event doesn’t bubble and is cancellable too.SyntaxFollowing is the syntax for −window.addEventListener("storage", SCRIPT);ExampleLet us look at an example for the Storage Event − Storage Event Example Create the visit localStorage item by clicking the below button CREATE var y=1; window.addEventListener("storage", DisplayChange); function DisplayEvent(event) { document.getElementById("Sample").innerHTML = "The number of visits has been ... Read More
In this section we will see some examples of code shortening strategy for competitive programming. Suppose we have to write some large amount of codes. In that code, we can follow some strategy to make them more short.We can change the type-name to make it short. Please check the code to get the ideaExample Code#include using namespace std; int main() { long long x = 10; long long y = 50; cout
Here we will see one space optimized approach for LCS problem. The LCS is the longest common subsequence. If two strings are “BHHUBC” and “HYUYBZC”, then the length of the subsequence is 4. One dynamic programming approach is already their, but using the dynamic programming approach, it will take more space. We need table of order m x n, where m is the number of characters in first string, and n is the number of characters in the second string.Here we will see how to implement this algorithm using O(n) amount of auxiliary space. If we observe the old approach ... Read More
Suppose we have one graph like below. That graph is Peterson graph. The vertices are numbered from 0 through 9. Each vertex has some letters. Let consider one walk W, in that graph, where L vertices are used. A string S with L letters is realized by the walk W when the letter sequence in W and S are same. We can visit the vertices multiple times.For example, one string S is like “ABBECCD”, this is realized by the walk (0, 1, 6, 9, 7, 2, 3). Our task is to find such walk, and if that walk is present, ... Read More
Suppose we have one integer variable whose size is 4 byte, another pointer variable is there, whose size is 8 bytes. So what will be the output of the following?Example#include using namespace std; main() { int a[4][5][6]; int x = 0; int* a1 = &x; int** a2 = &a1; int*** a3 = &a2; cout
Here we will see one Boolean array puzzle. One array is given with two elements 0 and 1. We have to make all elements to 0. There are some specifications that we should consider −In the array one element is 0, that is fixed, but we do not know what is the position of that elementThe other element can be 0 or 1Only complement operation is allowed here, no other operations cannot be performedWe cannot use branching and loop statementsWe cannot assign 0 directly to the array elementsWe can solve this problem in different ways. There are three of them ... Read More
 
 Data Structure
 Data Structure Networking
 Networking RDBMS
 RDBMS Operating System
 Operating System Java
 Java MS Excel
 MS Excel iOS
 iOS HTML
 HTML CSS
 CSS Android
 Android Python
 Python C Programming
 C Programming C++
 C++ C#
 C# MongoDB
 MongoDB MySQL
 MySQL Javascript
 Javascript PHP
 PHP 
		