code-rag-bench/online-tutorials huggingface dataset:
RxJava - Filtering Operators

Following are the operators which are used to selectively emit item(s) from an Observable.
Debounce
Emits items only when timeout occurs without emiting another item.
Distinct
Emits only unique items.
ElementAt
emit only item at n index emitted by an Observable.
Filter
Emits only those items which pass the given predicate function.
First
Emits the first item or first item which passed the given criteria.
IgnoreElements
Do not emits any items from Observable but marks completion.
Last
Emits the last element from Observable.
Sample
Emits the most recent item with given time interval.
Skip
Skips the first n items from an Observable.
SkipLast
Skips the last n items from an Observable.
Take
takes the first n items from an Observable.
TakeLast
takes the last n items from an Observable.
Create the following Java program using any editor of your choice in, say, C:\> RxJava.
import io.reactivex.Observable;
//Using take operator to filter an Observable
public class ObservableTester  {
   public static void main(String[] args) {    
      String[] letters = {"a", "b", "c", "d", "e", "f", "g"};
      final StringBuilder result = new StringBuilder();
      Observable<String> observable = Observable.fromArray(letters);
      observable
         .take(2)
         .subscribe( letter -> result.append(letter));
      System.out.println(result);
   }
}
Compile the class using javac compiler as follows −
C:\RxJava>javac ObservableTester.java

Now run the ObservableTester as follows −
C:\RxJava>java ObservableTester

It should produce the following output −
ab

 Print
 Add Notes
 Bookmark this page
How to remove the redundant elements from an ArrayList object in java?

The interface set does not allow duplicate elements. The add() method of this interface accepts elements and adds to the Set object, if the addition is successful it returns true if you try to add an existing element using this method, the addition operations fails to return false.
Therefore, to remove redundant elements of an ArrayList object −
Get/create the required ArrayList.
Get/create the required ArrayList.
Create an empty set object.
Create an empty set object.
Try to add all the elements of the ArrayList object to set objectives.
Try to add all the elements of the ArrayList object to set objectives.
Clear the contents of the ArrayList using the clear() method.
Clear the contents of the ArrayList using the clear() method.
Now, using the addAll() method add the contents of the set object to the ArrayList again.
Now, using the addAll() method add the contents of the set object to the ArrayList again.
 Live Demo
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class RemovingDuplicates {
   public static void main(String[] args){
      //Instantiating an ArrayList object
      ArrayList<String> list = new ArrayList<String>();
      list.add("JavaFX");
      list.add("Java");
      list.add("JavaFX");
      list.add("OpenCV");
      list.add("Java");
      list.add("JOGL");
      list.add("JOGL");
      list.add("HBase");
      list.add("Flume");
      list.add("HBase");
      list.add("Impala");
      System.out.println("Contents of the Array List : \n"+list);
      //Retrieving Iterator object of the ArrayList class
      Iterator<String> it = list.iterator();
      //Creating an empty Set object
      Set<String> set = new HashSet<String>();
      //Adding elements of the ArrayList to the Set object
      while(it.hasNext()) {
         set.add(it.next());
      }
      //Removing all the elements from the ArrayList
      list.clear();
      //Adding elements of the set back to the list
      list.addAll(set);
      System.out.println("Contents of the Array List after removing duplicate elements: \n"+list);
   }
}
Contents of the Array List :
[JavaFX, Java, JavaFX, OpenCV, Java, JOGL, JOGL, HBase, Flume, HBase, Impala]
Contents of the Array List after removing duplicate elements:
[JavaFX, Java, OpenCV, JOGL, Flume, Impala, HBase]
Print JSON nested object in JavaScript?

To print JSON nested object in JavaScript, use for loop along with JSON.parse(). Following is
the code −
var details = [
   {
      "studentId": 101,
      "studentName": "John",
      "countryName": "US",
      "subjectDetails": "{\"0\":\"JavaScript\",\"1\":\"David\"}"
   },
   {
      "studentId": 102,
      "studentName": "Bob",
      "countryName": "UK",
      "subjectDetails": "{\"0\":\"Java\",\"1\":\"Carol\"}"
   },
   {
      "studentId": 103,
      "studentName": "Mike",
      "countryName": "AUS",
      "subjectDetails": "{\"0\":\"MongoDB\",\"1\":\"Adam\"}"
   }
]
for (const detailsObject of details) {
   const subjectDetailsObject =
   JSON.parse(detailsObject.subjectDetails);
   console.log(subjectDetailsObject[0]);
}
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo145.js.
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo145.js
JavaScript
Java
MongoDB
Program to count how many ways we can divide the tree into two trees in Python

Suppose we have a binary tree containing values 0, 1 and 2. The root has at least one 0 node and one 1 node. Now suppose there is an operation where we delete an edge in the tree and the tree becomes two different trees. We have to find the number of ways we can delete one edge such that none of the two trees contain both a 0 node and a 1 node.
So, if the input is like
then the output will be 1 as we can only delete the 0 to 2 edge.
To solve this, we will follow these steps −
count := [0, 0, 0]
Define a function dfs() . This will take node
if node is not null, thenpre := countdfs(left of node)dfs(right of node)count[value of node] := count[value of node] + 1node.count := a list of (count[i] - pre[i]) for i is 0 and 1
pre := count
dfs(left of node)
dfs(right of node)
count[value of node] := count[value of node] + 1
node.count := a list of (count[i] - pre[i]) for i is 0 and 1
Define a function dfs2() . This will take node, par
if node is not null, thenif par is not null, then(a0, a1) := count of node(b0, b1) := (count[0] - a0, count[1] - a1)if (a0 is same as 0 or a1 is same as 0) and (b0 is same as 0 or b1 is same as 0), thenans := ans + 1dfs2(left of node, node)dfs2(right of node, node)
if par is not null, then(a0, a1) := count of node(b0, b1) := (count[0] - a0, count[1] - a1)if (a0 is same as 0 or a1 is same as 0) and (b0 is same as 0 or b1 is same as 0), thenans := ans + 1
(a0, a1) := count of node
(b0, b1) := (count[0] - a0, count[1] - a1)
if (a0 is same as 0 or a1 is same as 0) and (b0 is same as 0 or b1 is same as 0), thenans := ans + 1
ans := ans + 1
dfs2(left of node, node)
dfs2(right of node, node)
From the main method, do the following −
dfs(root)
ans := 0
dfs2(root)
return ans
Let us see the following implementation to get better understanding −
 Live Demo
class TreeNode:
   def __init__(self, data, left = None, right = None):
      self.val = data
      self.left = left
      self.right = right
class Solution:
   def solve(self, root):
      count = [0, 0, 0]
   def dfs(node):
      if node:
         pre = count[:]
         dfs(node.left)
         dfs(node.right)
         count[node.val] += 1
         node.count = [count[i] - pre[i] for i in range(2)]
   dfs(root)
   def dfs2(node, par=None):
      if node:
         if par is not None:
            a0, a1 = node.count
            b0, b1 = count[0] - a0, count[1] - a1
            if (a0 == 0 or a1 == 0) and (b0 == 0 or b1 == 0):
               self.ans += 1
         dfs2(node.left, node)
         dfs2(node.right, node)
   self.ans = 0
   dfs2(root)
   return self.ans
ob = Solution()
root = TreeNode(0)
root.left = TreeNode(0)
root.right = TreeNode(2)
root.right.left = TreeNode(1)
root.right.right = TreeNode(1)
print(ob.solve(root))
root = TreeNode(0)
root.left = TreeNode(0)
root.right = TreeNode(2)
root.right.left = TreeNode(1)
root.right.right = TreeNode(1)
1
Java finally Keyword

❮ Java Keywords

Execute code, after try...catch, regardless of the result:
try {
  int[] myNumbers = {1, 2, 3};
  System.out.println(myNumbers[10]);
} catch (Exception e) {
  System.out.println("Something went wrong.");
} finally {
  System.out.println("The 'try catch' is finished.");
}


Try it Yourself »

The finally keyword is used to execute code (used with exceptions 
- try..catch statements) no matter if there is an exception or not.
Read more about exceptions in our Java Try..Catch Tutorial.

❮ Java Keywords

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Gson - Class

Gson is the main actor class of Google Gson library. It provides functionalities to convert Java objects to matching JSON constructs and vice versa. Gson is first constructed using GsonBuilder and then toJson(Object) or fromJson(String, Class) methods are used to read/write JSON constructs.
Following is the declaration for com.google.gson.Gson class:
public final class Gson
   extends Object
This class inherits methods from the following classes:
java.lang.Object
java.lang.Object
Create the following java program using any editor of your choice in say C:/> GSON_WORKSPACE
File: GsonTester.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class GsonTester {
   public static void main(String[] args){
      String jsonString = "{\"name\":\"Mahesh\", \"age\":21}";
      GsonBuilder builder = new GsonBuilder();
      builder.setPrettyPrinting();
      Gson gson = builder.create();
      Student student = gson.fromJson(jsonString, Student.class);
      System.out.println(student);		 
      jsonString = gson.toJson(student);
      System.out.println(jsonString);	
   }
}

class Student {
   private String name;
   private int age;
   public Student(){}
   public String getName() {
      return name;
   }
   public void setName(String name) {
      this.name = name;
   }
   public int getAge() {
      return age;
   }
   public void setAge(int age) {
      this.age = age;
   }
   public String toString(){
      return "Student [ name: "+name+", age: "+ age+ " ]";
   }	
}
Verify the result
Compile the classes using javac compiler as follows:
C:\GSON_WORKSPACE>javac GsonTester.java
Now run the GsonTester to see the result:
C:\GSON_WORKSPACE>java GsonTester
Verify the Output
Student [ name: Mahesh, age: 21 ]
{
  "name" : "Mahesh",
  "age" : 21
}

 Print
 Add Notes
 Bookmark this page
Minkowski distance in Python - GeeksforGeeks

16 Sep, 2021
Minkowski distance is a metric in a normed vector space. Minkowski distance is used for distance similarity of vector. Given two or more vectors, find distance similarity of these vectors.
Mainly, Minkowski distance is applied in machine learning to find out distance similarity.
Examples : 
Input : vector1 = 0 2 3 4
        vector2 = 2, 4, 3, 7
        p = 3

Output : distance1 = 3.5033

Input : vector1 = 1, 4, 7, 12, 23
        vector2 = 2, 5, 6, 10, 20
        p = 2

Output : distance2 = 4.0
Note : Here distance1 and distance2 are almost same so it will be in same near region.  
Python3
# Python3 program to find Minkowski distance # import math libraryfrom math import *from decimal import Decimal # Function distance between two points# and calculate distance value to given# root value(p is root value)def p_root(value, root):         root_value = 1 / float(root)    return round (Decimal(value) **             Decimal(root_value), 3) def minkowski_distance(x, y, p_value):         # pass the p_root function to calculate    # all the value of vector parallelly    return (p_root(sum(pow(abs(a-b), p_value)            for a, b in zip(x, y)), p_value)) # Driver Codevector1 = [0, 2, 3, 4]vector2 = [2, 4, 3, 7]p = 3print(minkowski_distance(vector1, vector2, p))
Output : 
3.503
Reference : https://en.wikipedia.org/wiki/Minkowski_distance 
ruhelaa48
Python
Python Programs
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Box Plot in Python using Matplotlib
Bar Plot in Matplotlib
Python | Get dictionary keys as a list
Python | Convert set into a list
Ways to filter Pandas DataFrame by column values
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python program to check whether a number is Prime or not
Python | Convert a list to dictionary
Convert string dictionary to dictionary in Python

In this article we'll see how to convert a given dictionary containing strings into a normal dictionary of key value pairs.
The json.loads can pass a given string and give us the result as normal strings preserving the structure of the data. So we pass the given string dictionary into this function as a parameter and get our result.
 Live Demo
import json
stringA = '{"Mon" : 3, "Wed" : 5, "Fri" : 7}'
# Given string dictionary
print("Given string : \n",stringA)
# using json.loads()
res = json.loads(stringA)
# Result
print("The converted dictionary : \n",res)
Running the above code gives us the following result −
Given string :
{"Mon" : 3, "Wed" : 5, "Fri" : 7}
The converted dictionary :
{'Mon': 3, 'Wed': 5, 'Fri': 7}
This method from ast module works similar to the above approach. The dictionary containing string gets parsed as normal values and produces the normal dictionary.
 Live Demo
import ast
stringA = '{"Mon" : 3, "Wed" : 5, "Fri" : 7}'
# Given string dictionary
print("Given string : \n",stringA)
# using json.loads()
res = ast.literal_eval(stringA)
# Result
print("The converted dictionary : \n",res)
Running the above code gives us the following result −
Given string :
{"Mon" : 3, "Wed" : 5, "Fri" : 7}
The converted dictionary :
{'Fri': 7, 'Mon': 3, 'Wed': 5}
How to compare only date part without comparing time in JavaScript?

To compare only date part without comparing time, set the hours using the setHours() method. This will restrict the time to be compared while comparing both and time −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         var date1, date2;
         date1 = new Date();
         date1.setHours(0,0,0,0);
         document.write(date1);
         date2 = new Date( "Jan 01, 2018" );
         document.write("<br>" +date2);
         if (date1.getTime() === date2.getTime()) {
            document.write("<br>Both the dates are equal.");
         } else {
            document.write("<br>Both the dates aren't equal.");
         }
      </script>
   </body>
</html>
Fri May 25 2018 00:00:00 GMT+0530 (India Standard Time)
Mon Jan 01 2018 00:00:00 GMT+0530 (India Standard Time)
Both the dates aren't equal.
What is greater-than sign (>) selector in CSS?

30 Jul, 2021
The greater than sign (>) selector in CSS is used to select the element with a specific parent. It is called as element > element selector. It is also known as the child combinator selector which means that it selects only those elements which are direct children of a parent. It looks only one level down the markup structure and not further deep down. Elements which are not the direct child of the specified parent is not selected.
Syntax:
element > element {
    // CSS Property
}
Example-1: This example describes the greater than > selector.
<!DOCTYPE html> <html>     <head>         <title>             CSS element > element Selector         </title>         <style>             ul > li {                 color:white;                 background: green;             }         </style>     </head>     <body>         <h2 style = "color:green;">             CSS element > element Selector         </h2>                   <div>Searching algorithms</div>                   <ul>             <li>Binary search</li>             <li>Linear search</li>         </ul>                   <p>Sorting Algorithms</p>         <ul>             <li>Merge sort</li>             <li>Quick sort</li>         </ul>     </body> </html> 
Output:
Example 2: This example describes the greater than > selector.
<!DOCTYPE html> <html>     <head>         <title>             CSS element > element Selector         </title>                   <!-- style to set element > element selector -->        <style>             li > div {                 color:white;                 background: green;             }             ul > li {                color: green;            }        </style>     </head>           <body>         <h2 style = "color:green;">             CSS element > element Selector         </h2>                   <ul>            <li>                <div>Searching algorithms</div>                           <ul>                     <li>Binary search</li>                     <li>Linear search</li>                 </ul>            </li>                       <li>                <div>Sorting Algorithms</div>                 <ul>                     <li>Merge sort</li>                     <li>Quick sort</li>                 </ul>            </li>        </ul>    </body> </html> 
Output:
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
CSS-Misc
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How HTTP POST request work in Node.js?

07 Oct, 2021
POST is a request method supported by HTTP used by the World Wide Web. The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header. We use Express.js in order to create a server and to make requests (GET, POST, etc).
npm i express
Note: The npm in the above commands stands for node package manager, a place from where we install all the dependencies.
So in order to use Express to address POST requests on our server, we use the app.post method and then we specify the route, and we have a callback.
app.post(route, function(req, res){
    //this is a callback function
})
Note: If you are going to make GET, POST request frequently in NodeJS, then use Postman , Simplify each step of building an API.
In this syntax, the route is where you have to post your data that is fetched from the HTML. For fetching data you can use bodyparser package.
Web Server: Create app.js in the root folder. Create your server as shown in the below example.
javascript
const express = require("express");const app = express();  // Define routes here ...  app.listen(3000, function(){  console.log("server is running on port 3000");})
Handle Post Request: Here you will learn how to handle HTTP POST request and get data from the submitted form. 
Create index.html in the root folder of your application and write following HTML code in it.
Filename: index.html  
html
<!DOCTYPE html><html lang="en" dir="ltr">  <head>    <meta charset="utf-8">    <title>Calculator</title></head>  <body>    <h1>Simple Calculator.</h1>    <form action="/" method="post">        <input type="text" name="num1"             placeholder="First Number">        <input type="text" name="num2"             placeholder="Second Number">                      <button type="submit" name="submit">            calculator        </button>    </form></body>  </html>
Output:
Handle POST Route in Express.js: Filename: app.js  
javascript
const express = require("express");const bodyParser = require("body-parser")  // New app using express moduleconst app = express();app.use(bodyParser.urlencoded({    extended:true}));  app.get("/", function(req, res) {  res.sendFile(__dirname + "/index.html");});  app.post("/", function(req, res) {  var num1 = Number(req.body.num1);  var num2 = Number(req.body.num2);      var result = num1 + num2 ;      res.send("Addition - " + result);});  app.listen(3000, function(){  console.log("server is running on port 3000");})
Steps To Run:
npm init 
npm install express
npm install body-parser
node app.js
go to http://localhost:3000 in your browser.
Output: 
mridulmanochagfg
Node.js-Misc
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Program for Find minimum sum of factors of number

22 Jun, 2022
Given a number, find minimum sum of its factors.Examples:  
Input : 12
Output : 7
Explanation: 
Following are different ways to factorize 12 and
sum of factors in different ways.
12 = 12 * 1 = 12 + 1 = 13
12 = 2 * 6 = 2 + 6 = 8
12 = 3 * 4 = 3 + 4 = 7
12 = 2 * 2 * 3 = 2 + 2 + 3 = 7
Therefore minimum sum is 7

Input : 105
Output : 15
 
Python3
# Python program to find minimum# sum of product of number  # To find minimum sum of# product of numberdef findMinSum(num):    sum = 0         # Find factors of number    # and add to the sum    i = 2    while(i * i <=num):        while(num % i == 0):            sum += i            num //= i        i += 1    sum += num         # Return sum of numbers    # having minimum product    return sum # Driver Codenum = 12print (findMinSum(num)) # This code is contributed by Sachin Bisht
Output:  
7
Time Complexity: O(n1/2 * log n)
Auxiliary Space: O(1)
Please refer complete article on Find minimum sum of factors of number for more details! 
amartyaghoshgfg
amanjhaa15915
chandramauliguptach
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert string dictionary to dictionary
Python program to add two numbers
Python Program for Binary Search (Recursive and Iterative)
Python Program for factorial of a number
Iterate over characters of a string in Python
Python program to find second largest number in a list
Python program to interchange first and last elements in a list
Python | Convert set into a list
Appending to list in Python dictionary
Python program to find sum of elements in list
Python – turtle.Screen().setup() method

20 Aug, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This method is used to set the size and position of the main window.
Syntax : turtle.Screen().setup(width=0.5, height=0.75, startx=None, starty=None)
Parameters: This method has following parameters:
width: as integer a size in pixels, as float a fraction of the screen. Default is 50% of screen.
height: as integer the height in pixels, as float a fraction of the screen. Default is 75% of screen.
startx: if positive, starting position in pixels from the left edge of the screen, if negative from the right edge. Default, startx=None is to center window horizontally.
starty: if positive, starting position in pixels from the top edge of the screen, if negative from the bottom edge. Default, starty=None is to center window vertically.
                                        
Below is the implementation of above method with some examples :
Example 1: Change the configuration of the window.
Python3
# import turtle packageimport turtle  # making turtle objectsc = turtle.Screen()  # setup the screen sizesc.setup(400,400)  # set the background colorsc.bgcolor("blue")  # This code is contributed# by Deepanshu Rustagi.
Output :
Example 2: Change the position of the window by setting up the ‘startx’ and ‘starty’ in setup() method.
Python3
# import turtle packageimport turtle  # making turtle objectsc = turtle.Screen()  # set the screen size 400x400 pixels# set the screen position by# startx to 50# starty to-200sc.setup(400, 400, startx = 50,         starty = -200)  # set the background colorsc.bgcolor("blue")  # This code is contributed # by Deepanshu Rustagi.
Output :
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – DROP TABLESPACE

08 Feb, 2021
In PostgreSQL, the DROP TABLESPACE statement is used to remove a tablespace.
Syntax: DROP TABLESPACE [IF EXISTS] tablespace_name;
Let’s analyze the above syntax:
First, specify the name of the tablespace that is to be deleted after the DROP TABLESPACE keywords.
Second, use the IF EXISTS option to handle errors in case the tablespace doesn’t exists.
Note: It is important to note that only tablespace owners or superusers can execute the DROP TABLESPACE statement.
Example:
First, we create a new tablespace named gfg and map it to the C:\data\gfg directory:
CREATE TABLESPACE gfg
LOCATION 'C:\data\gfg';
Now create a database named db_gfg and set its tablespace to gfg: 
CREATE DATABASE db_gfg 
TABLESPACE = gfg;
Now create a new table named test in the db_gfg and set it tablespace to gfg:
CREATE TABLE test (
    ID serial PRIMARY KEY,
    title VARCHAR (255) NOT NULL
) TABLESPACE gfg;
The following statement returns all objects in the gfg tablespace:
SELECT
    table_space.spcname,
    class.relname
FROM
    pg_class class
JOIN pg_tablespace table_space 
    ON class.reltablespace = table_space.oid
WHERE
    table_space.spcname = 'gfg';
This will lead to the following:
Now if you try to drop the gfgtablespace:
DROP TABLESPACE gfg;
This will raise the following error:
As the gfg tablespace is not empty,it is not possible to drop the tablespace. Now, login to the Postgres database and drop the db_gfg database:
DROP DATABASE db_gfg;
Now delete the gfg tablespace again:
DROP TABLESPACE gfg;
Now check for the tablespace using the below command to verify:
\db+
Output:
postgreSQL-administration
postgreSQL-managing-table
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - REPLACE Function
PostgreSQL - DROP INDEX
PostgreSQL - INSERT
PostgreSQL - TIME Data Type
PostgreSQL - ROW_NUMBER Function
PostgreSQL - EXISTS Operator
PostgreSQL - CREATE SCHEMA
PostgreSQL - LEFT JOIN
PostgreSQL - SELECT
How to get font properties of particular element in JavaScript ?

18 Jun, 2019
Give a string element and the task is to get the font properties of a particular element using JavaScript.
Approach:
Store a string to the variable.
Then use element.style.property to get the propertyValue of that element property.
Example 1: This example gets the font-family of the element [id = ‘GFG_UP’].
<!DOCTYPE HTML> <html>     <head>         <title>             How to get the font family property of            a particular element in JavaScript ?        </title>    </head>           <body style = "text-align:center;">                   <h1 style = "color:green;" >             GeeksForGeeks         </h1>                   <p id = "GFG_UP" style =            "font-size: 16px; font-family: sans-serif; font-weight: bold;">             </p>                  <button onclick = "gfg_Run()">             Click here        </button>                  <p id = "GFG_DOWN" style =             "color:green; font-size: 30px; font-weight: bold;">        </p>                  <script>            var el_up = document.getElementById("GFG_UP");            var el_down = document.getElementById("GFG_DOWN");                      var str = "click on button to get the font property";                      el_up.innerHTML = str;                      function gfg_Run() {                el_down.innerHTML =                    "font-style is '" + el_up.style.fontFamily + "'";            }                 </script>     </body> </html>
Output:
Before clicking on the button:
After clicking on the button:
Example 2: This example gets the font-weight of the element [id = ‘GFG_UP’].
<!DOCTYPE HTML>  <html>      <head>         <title>             How to get the font weight property of            a particular element in JavaScript ?        </title>    </head>           <body style = "text-align:center;">                    <h1 style = "color:green;" >              GeeksForGeeks          </h1>                   <p id = "GFG_UP" style =             "font-size: 16px; font-family: sans-serif; font-weight: bold;">             </p>                  <button onclick = "gfg_Run()">             Click here        </button>                  <p id = "GFG_DOWN" style =            "color:green; font-size: 30px; font-weight: bold;">        </p>                  <script>            var el_up = document.getElementById("GFG_UP");            var el_down = document.getElementById("GFG_DOWN");                          var str = "click on button to get the font property";                          el_up.innerHTML = str;                          function gfg_Run() {                el_down.innerHTML =                     "font-weight is '"+el_up.style.fontWeight + "'";            }                   </script>     </body>  </html>
Output:
Before clicking on the button:
After clicking on the button:
JavaScript-Misc
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Maximum value of unsigned long long int in C++

03 Dec, 2020
In this article, we will discuss the unsigned long long int data type in C++. It is the largest (64 bit) integer data type in C++. 
Some properties of the unsigned long long int data type are:
An unsigned data type stores only positive values.
It takes a size of 64 bits.
A maximum integer value that can be stored in an unsigned long long int data type is 18, 446, 744, 073, 709, 551, 615, around 264 – 1(but is compiler dependent).
The maximum value that can be stored in unsigned long long int is stored as a constant in <climits> header file whose value can be used as ULLONG_MAX.
The minimum value that can be stored in unsigned long long int is zero.
In case of overflow or underflow of data type, the value is wrapped around. For example, if 0 is stored in an unsigned long long int data type and 1 is subtracted from it, the value in that variable will become equal to 18, 446, 744, 073, 709, 551, 615. Similarly, in the case of overflow, the value will round back to 0.
Below is the program to get the highest value that can be stored in unsigned long long int in C++:
C++
// C++ program to obtain the maximum// value stored in unsigned long long int#include <climits>#include <iostream>using namespace std;  // Driver Codeint main(){      // From the constant of climits    // header file    unsigned long long int valueFromLimits = ULLONG_MAX;      cout << "Value from climits "         << "constant: ";    cout << valueFromLimits << "\n";      // Using the wrap around property    // of data types      // Initialize a variable with value 0    unsigned long long int value = 0;      // Subtract 1 from value since an    // unsigned data type cannot store    // negative number, the value will    // wrap around  and stores maximum    // value stored in it    value = value - 1;    cout << "Value using the wrap"         << " around property: "         << value << "\n";      return 0;}
Value from climits constant: 18446744073709551615
Value using the wrap around property: 18446744073709551615

Data Type
Data Types
large-numbers
C++
C++ Programs
Data Type
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2013 | Question 25

10 May, 2018
Consider the following dependencies and the BOOK table in a relational database design. Determine the normal form of the given relation.
ISBN → Title
 ISBN → Publisher
 Publisher → Address 
(A) First Normal Form(B) Second Normal Form(C) Third Normal Form(D) BCNFAnswer: (B)Explanation: Candidate key = ISBNFor a relation having functional dependencies of the form α → β, a relation is in 2-NF if:i) α should not be a proper subset of the candidate key, or,ii) β – α should be a prime attribute.
First condition satisfies as the candidate key contains only one attribute.
So, this relation is in 2-NFQuiz of this Question
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Add 2 hours to current time in MySQL?

We can get the current time with the help of now() and adding 2 hours is done by giving the interval as 2. Firstly, collect information of the current time in the system with the help of now(). The current time is .
The following is the query to get the current date and time.
mysql> select now();
Here is the output.
+---------------------+
| now()               |
+---------------------+
| 2018-11-01 12:58:40 |
+---------------------+
1 row in set (0.00 sec)

To add 2 hours in the current time, we will use the DATE_ADD() function.
mysql> select DATE_ADD(now(),interval 2 hour);
The following is the output that displays.
+---------------------------------+
| DATE_ADD(now(),interval 2 hour) |
+---------------------------------+
| 2018-11-01 14:58:31             |
+---------------------------------+
1 row in set (0.00 sec)
How to remove Ttk Notebook Tab Dashed Line? (tkinter)

In order to work with Tabs and separate your workflow in an application, Tkinter provides a Notebook widget. We can use the Notebook widget to create Tabs in an application. Tabs are useful to isolate one particular frame or event from another.
Generally, Notebook widget can be configured and styled using the ttk themed widget. So, to style a Notebook widget, we pass TNotebook and TNotebook.Tab parameters in the configuration. If we click on a particular Tab, there may appear some rectangular dashed line which can be removed.
# Import the required library
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame
win = Tk()
win.geometry("700x350")

# Create an instance of ttk
style = ttk.Style()

# Define Style for Notebook widget
style.layout("Tab", [('Notebook.tab', {'sticky': 'nswe', 'children':
   [('Notebook.padding', {'side': 'top', 'sticky': 'nswe', 'children':
      [('Notebook.label', {'side': 'top', 'sticky': ''})],
   })],
})]
)

# Use the Defined Style to remove the dashed line from Tabs
style.configure("Tab", focuscolor=style.configure(".")["background"])

# Create a Notebook widget
my_notebook= ttk.Notebook(win)
my_notebook.pack(expand=1,fill=BOTH)

# Creating Tabs
tab1 = ttk.Frame(my_notebook)
my_notebook.add(tab1, text= "Tab 1")
tab2 = ttk.Frame(my_notebook)
my_notebook.add(tab2, text= "Tab2")

# Create a Label in Tabs
Label(tab1, text= "Hello, Howdy?",
   font = ('Helvetica 20 bold')).pack()
Label(tab2, text= "This is a New Tab Context",
   font = ('Helvetica 20 bold')).pack()
win.mainloop()
Executing the above code will display a window containing multiple tabs.
When we switch tabs from the window, it will display its content
Empty string in not-null column in MySQL?

In PHP, the empty string equals to a NULL value, but in MySQL, the case is the different i.e. empty string is not equal to NULL value. To understand the above syntax, let us create a column with NOT NULL constraint while you can insert an empty string.
Let us create a table. The query to create a table is as follows −
mysql> create table EmptyStringNotNullDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> Name varchar(10) not null,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.83 sec)
Now you can insert some records in the table to check the empty string is null or not null. The query to insert record is as follows −
mysql> insert into EmptyStringNotNullDemo(Name) values('John');
Query OK, 1 row affected (0.17 sec)
mysql> insert into EmptyStringNotNullDemo(Name) values('');
Query OK, 1 row affected (0.43 sec)
mysql> insert into EmptyStringNotNullDemo(Name) values('Carol');
Query OK, 1 row affected (0.12 sec)
mysql> insert into EmptyStringNotNullDemo(Name) values('');
Query OK, 1 row affected (0.13 sec)
mysql> insert into EmptyStringNotNullDemo(Name) values('');
Query OK, 1 row affected (0.16 sec)
mysql> insert into EmptyStringNotNullDemo(Name) values('Larry');
Query OK, 1 row affected (0.14 sec)
Display all records from the table using a select statement. The query is as follows −
mysql> select *from EmptyStringNotNullDemo;
The following is the output −
+----+-------+
| Id | Name  |
+----+-------+
|  1 | John  |
|  2 |       |
|  3 | Carol |
|  4 |       |
|  5 |       |
|  6 | Larry |
+----+-------+
6 rows in set (0.00 sec)
Now check the empty string is NULL or NOT NULL in MySQL. If you get a 0 that would mean the empty string is not equal to a NULL otherwise empty string is NULL. The query is as follows −
mysql> select Name, Name IS NULL as EmptyValueIsNotNULL from EmptyStringNotNullDemo;
The following is the output −
+-------+---------------------+
| Name  | EmptyValueIsNotNULL |
+-------+---------------------+
| John  |                   0 |
|       |                   0 |
| Carol |                   0 |
|       |                   0 |
|       |                   0 |
| Larry |                   0 |
+-------+---------------------+
6 rows in set (0.00 sec)
You can achieve with the help of user-defined variable. The syntax is as follows −
SET @anyVariableName=” ”;
UPDATE yourTableName SET yourColumnName= @anyVariableName;
Implement the above syntax for the given table. The query is as follows to declare and define a user variable.
mysql> set @emptyStringValue="";
Query OK, 0 rows affected (0.00 sec)
Update the table with an empty string. The query is as follows −
mysql> update EmptyStringNotNullDemo set Name=@emptyStringValue;
Query OK, 3 rows affected (0.25 sec)
Rows matched: 6 Changed: 3 Warnings: 0
Display all records from the table once again. The query is as follows −
mysql> select *from EmptyStringNotNullDemo;
The following is the output −
+----+------+
| Id | Name |
+----+------+
|  1 |      |
|  2 |      |
|  3 |      |
|  4 |      |
|  5 |      |
|  6 |      |
+----+------+
6 rows in set (0.00 sec)
The column ‘Name’ has been updated.
C# Program to generate random lowercase letter

Firstly, set Random class −
Random random = new Random();
Set a range under the Next() method. This displays a letter between 0 and 26.
int a = random.Next(0, 26);
Here is the complete code −
 Live Demo
using System;
using System.IO;
using System.Linq;
class Demo {
   static void Main() {
      Random random = new Random();
      // random lowercase letter
      int a = random.Next(0, 26);
      char ch = (char)('a' + a);
      Console.WriteLine(ch);
   }
}
t
Valid Mountain Array in Python

Suppose we have an array A of integers; we have to check whether it is a valid mountain array or not. We know that A is a mountain array if and only if it satisfies the following situations − size of A >= 3
There exists some index i in A such that −
A[0] < A[1] < ... A[i-1] < A[i]
A[i] > A[i+1] > ... > A[A.length - 1]
So, if the input is like [0,3,2,1], then the output will be True.
To solve this, we will follow these steps −
if size of A < 3, thenreturn False
return False
i := 1
while i < size of A and A[i] > A[i-1], doi := i + 1
i := i + 1
if i is same as 1 or i is same as size of A , thenreturn False
return False
while i < size of A and A[i] < A[i-1], doi := i + 1
i := i + 1
return true when i is same as size of A
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def validMountainArray(self, A):
      if(len(A)<3):
         return False
         i = 1
      while(i<len(A) and A[i]>A[i-1]):
         i+=1
      if(i==1 or i==len(A)):
         return False
      while(i<len(A) and A[i]<A[i-1]):
         i+=1
      return i==len(A)
ob = Solution()
print(ob.validMountainArray([0,3,2,1]))
[0,3,2,1]
True
Phone Number validation using Java Regular Expressions

The phone number can be validated using the java.util.regex.Pattern.matches() method. This method matches the regular expression for the phone number and the given input phone number and returns true if they match and false otherwise.
Note: We are considering a demo number for our example since we cannot use our phone number publicly.
A program that demonstrates this is given as follows:
 Live Demo
public class Demo {
   public static void main(String args[]) {
      String phoneNumber = "9999999998";
      String regex = "(0/91)?[7-9][0-9]{9}";
      System.out.println("The phone number is: " + phoneNumber);
      System.out.println("Is the above phone number valid? " + phoneNumber.matches(regex));
   }
}
The phone number is: 9999999998
Is the above phone number valid? True
Now let us understand the above program.
The phone number is printed. The Pattern.matches() method matches the regular expression for the phone number and the given input phone number and the result is printed. A code snippet which demonstrates this is as follows:
String phoneNumber = "9999999998";
String regex = "(0/91)?[7-9][0-9]{9}";

System.out.println("The phone number is: " + phoneNumber);
System.out.println("Is the above phone number valid? " + phoneNumber.matches(regex));
Compare *ptr++, *++ptr and ++*ptr in C++

In this section, we will see what are the differences between *ptr++, *++ptr and ++*ptr in C++.
Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has a priority higher than both prefix ++ and dereference operator ‘*’.
When ptr is a pointer, then *ptr++ indicates *(ptr++) and ++*prt refers ++(*ptr)
 Live Demo
#include<iostream>
using namespace std;

int main() {
   char arr[] = "Hello World";
   char *ptr = arr;
   ++*ptr;
   cout << *ptr;
   return 0;
}
I
So here at first ptr is pointing ‘H’. after using ++*ptr it increases H by 1, and now the value is ‘I’.
 Live Demo
#include<iostream>
using namespace std;

int main() {
   char arr[] = "Hello World";
   char *ptr = arr;
   *ptr++;
   cout << *ptr;
   return 0;
}
e
So here at first ptr is pointing ‘H’. after using *ptr++ it increases the pointer, so ptr will point to the next element. so the result is ‘e’.
 Live Demo
#include<iostream>
using namespace std;

int main() {
   char arr[] = "Hello World";
   char *ptr = arr;
   *++ptr;
   cout << *ptr;
   return 0;
}
e
In this example also we are increasing the ptr using ++, where the precedence of pre-increment ++ is higher, then it increases the pointer first, then taking the value using *. so it is printing ‘e’.
Count number of squares in a rectangle in C++

We are given with a rectangle of length L and breadth B, such that L>=B. The goal is to find the number of squares that a rectangle of size LXB can accommodate.
Above figure shows a rectangle of size 3 X 2. It has 2, 2X2 squares and 6,1X1 squares in it.
Total squares= 6+2=8.
Every rectangle of size LXB has L*B number of 1X1 squares.
Every rectangle of size LXB has L*B number of 1X1 squares.
Biggest squares are of size BXB.
Biggest squares are of size BXB.
For L=B=1, squares = 1.
For L=B=1, squares = 1.
For L=B=2, squares = 1 + 4 = 5. ( 1 of 2X2, 4 of 1X1 )
For L=B=2, squares = 1 + 4 = 5. ( 1 of 2X2, 4 of 1X1 )
For L=B=3, squares = 1 + 4 + 9 = 14. ( 1 of 3X3, 4 of 2X2, 9 of 1X1 )
For L=B=3, squares = 1 + 4 + 9 = 14. ( 1 of 3X3, 4 of 2X2, 9 of 1X1 )
For L=B=4, squares = 1 + 4 + 9 + 16 = 30 ( 1 of 4X4, 4 of 3X3, 9 of 2X2, 16 of 1X1 )
For L=B=4, squares = 1 + 4 + 9 + 16 = 30 ( 1 of 4X4, 4 of 3X3, 9 of 2X2, 16 of 1X1 )
.................
.................
For every BXB rectangle number of squares is
For every BXB rectangle number of squares is
for ( i=1 to B )
No. of squares + = i*i.
When L>B. More squares will be added. When L=B+1 ( 1 extra column than B ). Then squares added will be L + ( L-1) + ....+3+2+1 = L(L+1)/2
So for extra L-B columns squares added will be ( L-B ) * (B)(B+1)/2
Total squares will be squares in BXB + (L-B) * (L)(L+1)/2.
Total squares will be squares in BXB + (L-B) * (L)(L+1)/2.
You can also use formula B(B+1)(2B+1)/6 for the series (1 + 4 + 9 +......BXB) in step 8.
You can also use formula B(B+1)(2B+1)/6 for the series (1 + 4 + 9 +......BXB) in step 8.
Let’s understand with examples.
Input − L=4, B=2
Output − Count of squares in rectangle − 11
Explanation − 8 squares of 1X1 and 3 of 2X2.
Input − L=3, B=3
Output − Count of squares in rectangle − 14
Explanation − 9 squares of 1X1 , 4 of 2X2 and 1 of 3X3.
We take an integers length and breadth for dimensions of rectangle.
We take an integers length and breadth for dimensions of rectangle.
Function numofSquares(int l, int b) takes dimensions and returns the number of squares in the rectangle of size lXb.
Function numofSquares(int l, int b) takes dimensions and returns the number of squares in the rectangle of size lXb.
For biggest squares bXb. Use for loop from 1 to b and add each i*i to squares.
For biggest squares bXb. Use for loop from 1 to b and add each i*i to squares.
Now if l>b. New added squares will be (l-b)(b)(b+1)/2. Add this to squares.
Now if l>b. New added squares will be (l-b)(b)(b+1)/2. Add this to squares.
Return squares as desired result.
Return squares as desired result.
Note − keeping length>=breadth
 Live Demo
#include<iostream>
using namespace std;
int numofSquares(int l, int b){
   int squares=0;
   for(int i=1;i<=b;i++) //squares inside biggest square of size breadth X breadth{
      squares += i*i;
   }
   squares+=(l-b)*b*(b+1)/2;
   return squares;
}
int main(){
   int length = 5, breadth = 4; //keep length always >= breadth
   cout << "Count of squares is :"<< numofSquares(length,breadth);
}
If we run the above code it will generate the following output −
Count of squares is :40
How to remove duplicate values from a MySQL table using LEFT JOIN?

Let us first create a table −
mysql> create table DemoTable
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   FirstName varchar(100)
);
Query OK, 0 rows affected (0.46 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(FirstName) values('Chris');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable(FirstName) values('Robert');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable(FirstName) values('Robert');
Query OK, 1 row affected (0.07 sec)
mysql> insert into DemoTable(FirstName) values('John');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable(FirstName) values('John');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable(FirstName) values('Mike');
Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+-----------+
| Id | FirstName |
+----+-----------+
|  1 | Chris     |
|  2 | Robert    |
|  3 | Robert    |
|  4 | John      |
|  5 | John      |
|  6 | Mike      |
+----+-----------+
6 rows in set (0.00 sec)
Following is the query to remove duplicate values from MySQL table −
mysql> delete tbl from DemoTable tbl
left join(
   select min(Id) as Id, FirstName
   from DemoTable
   group by FirstName
) tbl1 ON tbl.Id = tbl1.Id AND tbl.FirstName = tbl1.FirstName
where tbl1.Id IS NULL;
Query OK, 2 rows affected (0.16 sec)
Let us check table records once again.
mysql> select *from DemoTable;
This will produce the following output −
+----+-----------+
| Id | FirstName |
+----+-----------+
|  1 | Chris     |
|  2 | Robert    |
|  4 | John      |
|  6 | Mike      |
+----+-----------+
4 rows in set (0.00 sec)
sr-only Bootstrap class

Hide an element to all devices except screen readers with the class .sr-only.
You can try to run the following code to implement the sr-only Bootstrap −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "row" style = "padding: 91px 100px 19px 50px;">
         <form class = "form-inline" role = "form">
            <div class = "form-group">
               <label class = "sr-only" for = "email">Email address</label>
               <input type = "email" class = "form-control" placeholder = "Enter email">
            </div>
            <div class = "form-group">
               <label class = "sr-only" for = "pass">Password</label>
               <input type = "password" class = "form-control" placeholder = "Password">
            </div>
         </form>
      </div>
   </body>
</html>