code-rag-bench/online-tutorials huggingface dataset:
HTML | DOM Select selectedIndex Property - GeeksforGeeks

28 Mar, 2019
The Select selectedIndex property in HTML DOM is used to set or return the index of the selected option in a drop-down list. The index of the drop-down list generally starts with 0 and returns -1 if no option is selected. This property returns the index of the first option if the drop-down list allows multiple selections.
Syntax:
It returns the Select selectedIndex property.selectObject.selectedIndex
selectObject.selectedIndex
It is used to set the Select selectedIndex property. selectObject.selectedIndex = number 
 selectObject.selectedIndex = number 
Property Values: It contains single value number which is used to specify the index of the selected option in a drop-down list.
Below program illustrates the Select selectedIndex property in HTML DOM:
Example: This example uses Select selectedIndex property to select the <option> element with index “3”.
<!DOCTYPE html><html>      <head>     <title>        HTML DOM Select selectedIndex Property    </title> </head>  <body style="text-align:center;">      <h1 style="color:green;">        GeeksforGeeks    </h1>           <h2 style="font-family: Impact;">        Select selectedIndex Property    </h2><br>          Select your preferred course from the drop-down list:<br>          <select name="Courses Titles" id="myCourses">        <option value="C++">c++</option>        <option value="Placement">Placement</option>        <option value="Java">Java</option>        <option value="Python">Python</option>    </select>          <p>        To select the option element with index "3",        double-click the "Return Element" button.    </p>          <button ondblclick="myGeeks()">        Return Element    </button>          <!-- This example uses Select selectedIndex Property -->    <script>        function myGeeks() {            document.getElementById("myCourses").selectedIndex                    = "3";        }    </script></body>  </html>                                                     
Output:Before Clicking the button:After Clicking the button:
Supported Browsers: The browser supported by DOM Select selectedIndex property are listed below:
Apple Safari
Internet Explorer
Firefox
Google Chrome
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
Form validation using HTML and JavaScript
Types of CSS (Cascading Style Sheet)
HTML Introduction
HTML | <img> align Attribute
Express.js express.Router() Function
Installation of Node.js on Linux
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
Convert a string to an integer in JavaScript
Python IMDbPY - Retrieving actor from the movie details - GeeksforGeeks

08 May, 2020
In this article we will see how we can retrieve the actors name performed in the movie from the movie information, movie id is the unique id given to each movie by IMDb. We can use search_movie method to search the movies by their name but it gives many movies as they have same names therefore retrieving a movie by its id is a better option.
In order to search a movie by its id we use get_movie method.
Syntax: [to get actors list] cast = movie[‘cast’]
Here movie is the object returned by the get_movie method which act as the dictionary
Below is the implementation.
# importing the moduleimport imdb  # creating instance of IMDbia = imdb.IMDb()  # IDcode = "1187043"  # getting moviemovie = ia.get_movie(code)  # printing movie objectprint(movie)  print("===============")  # getting castcast = movie['cast']  # actor name from casteactor = cast[0]  # printing actor nameprint(actor)
Output :
3 Idiots
===============
Aamir Khan
Another example –
# importing the moduleimport imdb  # creating instance of IMDbia = imdb.IMDb()  # IDcode = "4434004"  # getting moviemovie = ia.get_movie(code)  # printing movie objectprint(movie)  print("===============")  # getting castcast = movie['cast']  # actor name from casteactor = cast[0]  # printing actor nameprint(actor)
Output :
Udta Punjab
===============
Shahid Kapoor
Python IMDbPY-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Python Program to Find the Total Sum of a Nested List Using Recursion - GeeksforGeeks

25 Apr, 2022
A nested list is given. The task is to print the sum of this list using recursion. A nested list is a list whose elements can also be a list. 
Examples : 
Input: [1,2,[3]]
Output: 6

Input: [[4,5],[7,8,[20]],100]
Output: 144

Input: [[1,2,3],[4,[5,6]],7]
Output: 28
Recursion: In recursion, a function calls itself repeatedly. This technique is generally used when a problem can be divided into smaller subproblems of the same form.
Implementation:
Iterate through the list and whenever we find that an element of the list is also a list that means we have to do the same task of finding the sum with this element list (which can be nested) as well.  So we have found a subproblem and, we can call the same function to perform this task and just change the argument to this sublist. And when the element is not a list, then simply add its value to the global total variable.
Python3
# Python Program to find sum# of nested list using Recursion def sum_nestedlist( l ):       # specify that global variable is    # referred to here in this function    total = 0         for j in range(len(l)):               if type(l[j]) == list :                       # call the same function if            # the element is a list            total+= sum_nestedlist(l[j])        else:                       # if it's a single element            # and not a list, add it to total            total += l[j]                   return total             print(sum_nestedlist([[1,2,3],[4,[5,6]],7]))
28

Time Complexity: O(N), Where N is the total number of elements in the list.Auxiliary Space: O(1)
dcbriccetti
nitishei18
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
IDE | GeeksforGeeks | A computer science portal for geeks

Please enter your email address or userHandle.
12345678910111213141516171819202122232425262728293031323334353637#include <stdio.h>#include <stdlib.h>typedef struct node *pointer;struct node{        int data;    pointer next;};typedef pointer list;list AddNode(list node,int value){    list node1;    node1=node;           if(node1==NULL){               node1=(list)malloc(sizeof(struct node));        node1->data=value;        node1->next=NULL;            }    else    {               node1->next=AddNode(node1->next,value);    }   return node1;}void print(list node){        while(node!=NULL){               printf("%d ->",node->data);ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
https://ide.geeksforgeeks.org/bJUDxaqYd5
1 ->2 ->3 ->4 ->5 ->6 ->
To Check 
1 ->2 ->3 ->4 ->5 ->
Julia Keywords - GeeksforGeeks

26 Mar, 2020
Keywords in Julia are reserved words that have a predefined meaning to the compiler. They are used for some internal processes by the compiler. Keywords can’t be used as a variable name. Doing the same will result in a compile-time error.Example:
# Julia program to illustrate# the use of keywords  # Using 'for' keyword for i in 1:10          # Using if keyword    if i % 2 == 0        println(i, " is even")          # Using else keyword    else        println(i, " is odd")          # Using end keyword    endend
Output
1 is odd
2 is even
3 is odd
4 is even
5 is odd
6 is even
7 is odd
8 is even
9 is odd
10 is even

If we use a keyword as a variable name, the compiler will generate an error:
There are some keywords like abstract type, mutable struct, primitive type which are reserved but creation of variables with abstract, mutable, primitive and type is possible.
Julia-Basics
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Get array dimensions and size of a dimension in Julia - size() Method
Exception handling in Julia
Searching in Array for a given element in Julia
Find maximum element along with its index in Julia - findmax() Method
Get number of elements of array in Julia - length() Method
Join an array of strings into a single string in Julia - join() Method
Working with Excel Files in Julia
File Handling in Julia
Getting last element of an array in Julia - last() Method
Lodash _.trim() Method - GeeksforGeeks

18 Sep, 2020
The Lodash _.trim() Method removes leading and trailing white spaces or specified characters from the given string.
Syntax:
_.trim( string, chars )

Parameters: This method accepts two parameters as mentioned above and described below:
string: This parameter holds the string that need to be trimmed.
chars: This parameter holds the charset to be specifically trimmed.
Return Value: This method returns a trimmed string
Example 1:
Javascript
// Defining Lodash variable const _ = require('lodash');   var str = "   Geeks-for-Geeks   ";  // Using _.trim() methodconsole.log(_.trim(str));
Output:
Geeks-for-Geeks

Example 2: explicitly trimming “-” from the string.
Javascript
// Defining Lodash variable const _ = require('lodash');   var str = "----GeeksforGeeks----";  // Using _.trim() methodconsole.log(_.trim(str, "-"))
Output:
GeeksforGeeks

Note: This will not work in normal JavaScript because it requires the lodash library to be installed and can be installed using npm install lodash.
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Maximum Unique Element in every subarray of size K in c++

In this problem, we are given an array of integers and a integers K. our task is to create a program that will find the maximum unique element in every subarray of size K with no duplicates.
Let’s take an example to understand the problem,
Input −
array = {4, 1, 1, 3, 3}
k = 3
Output −
4 3 1
Explanation −
Sub-array of size 3
Subarray {4, 1, 1}, max = 4
Subarray {1, 1, 3}, max = 3
Subarray {1, 3, 3}, max = 1
To solve this problem, one simple method is to run two loops and create subarrays and find distinct elements and print a maximum of them.
But an effective solution is to use a sliding window method using a hash table and self-balancing BST to find maximum elements.
So, we will traverse the array and for k length summary store the counts of elements in hash table and store the elements in a set (which will store only unique elements). And the print the max of the set and do the same for every iteration in the array.
Program to illustrate the working of our solution,
 Live Demo
#include <bits/stdc++.h>
using namespace std;
void maxUniqueSubArrayElement(int A[], int N, int K){
   map<int, int> eleCount;
   for (int i = 0; i < K - 1; i++)
      eleCount[A[i]]++;
   set<int> uniqueMax;
   for (auto x : eleCount)
      if (x.second == 1)
         uniqueMax.insert(x.first);
   for (int i = K - 1; i < N; i++) {
      eleCount[A[i]]++;
      if (eleCount[A[i]] == 1)
          uniqueMax.insert(A[i]);
      else
         uniqueMax.erase(A[i]);
      if (uniqueMax.size() == 0)
         cout<<"-1\t" ;
      else
         cout<<*uniqueMax.rbegin()<<"\t";
      int x = A[i - K + 1];
      eleCount[x]--;
      if (eleCount[x] == 1)
         uniqueMax.insert(x);
      if (eleCount[x] == 0)
         uniqueMax.erase(x);
   }
}
int main(){
   int a[] = { 4, 3, 2, 2, 3, 5};
   int n = sizeof(a) / sizeof(a[0]);
   int k = 4;
   cout<<"The maximum unique element for a subarray of size "<<k<<" is\n";
      maxUniqueSubArrayElement(a, n, k);
   return 0;
}
The maximum unique element for a subarray of size 4 is 4 -1 5
Convert the .PNG to .GIF and it's vice-versa in Python - GeeksforGeeks

24 Jan, 2021
Prerequisites:
PIL
Tkinter
Python supports subsystems for converting one file format to another. This article discusses this topic and depicts how a png file can be converted to its gif equivalent and vice versa. For conversion of one file format to the other PIL is employed.
The given example uses a GUI interface to the code, so we will require Tkinter. It is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit which provide the interface to the GUI apps.
Import modules
Create a normal window
Add buttons to take choice whether to convert to png to gif or vice versa
Open file
Check if the file supplied is of the correct format
Convert to its respective equivalent
Save image
Execute code
Program:
Python3
from tkinter import *from tkinter import filedialog as fdimport osfrom PIL import Imagefrom tkinter import messagebox  root = Tk()  # naming the GUI interface to image_conversion_APProot.title("Image_Conversion_App")  # creating the Function which converts the jpg_to_png    def gif_to_png():    global im      import_filename = fd.askopenfilename()    if import_filename.endswith(".gif"):        im = Image.open(import_filename)        export_filename = fd.asksaveasfilename(defaultextension=".png")        im.save(export_filename)        messagebox.showinfo("Success", "File converted to .png")    else:        messagebox.showerror("Fail!!", "Error Interrupted!!!! Check Again")    def png_to_gif():    import_filename = fd.askopenfilename()    if import_filename.endswith(".png"):        im = Image.open(import_filename)        export_filename = fd.asksaveasfilename(defaultextension=".gif")        im.save(export_filename)        messagebox.showinfo("Success", "File converted to .gif")    else:        messagebox.showerror("Fail!!", "Error Interrupted!!!! Check Again")    button1 = Button(root, text="GIF_to_PNG", width=20, height=2, bg="green",                 fg="white", font=("helvetica", 12, "bold"), command=gif_to_png)  button1.place(x=120, y=120)  button2 = Button(root, text="PNG_to_GIF", width=20, height=2, bg="green",                 fg="white", font=("helvetica", 12, "bold"), command=png_to_gif)  button2.place(x=120, y=220)root.geometry("500x500+400+200")root.mainloop()
Output:
Python-pil
Technical Scripter 2020
Python
Python Programs
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
What is the use of test() method in JavaScript?

The test() method is a regular expression method. It searches a string for a pattern, and returns true or false, depending on the result. If it encountered the given pattern it returns true, else returns false. It is case sensitive. Let's discuss it in detail.
In the following example, a text named "Tutorix is the best e-learning platform" is given and a pattern "Tu" is checked whether it is present or not. Since the pattern is present the test() method returned true as output.
Live Demo
<html>
<body>
<p id="text">Tutorix is the best e-learning platform</p>
<p id="test"></p>
<script>
   var text = document.getElementById("text").innerHTML;
   document.getElementById("test").innerHTML = /Tu/.test(text);
</script>
</body>
</html>
Tutorix is the best e-learning platform
true
In the following example, a pattern "tu" is checked whether it is there in the provided text or not. If we clearly observe the text we have "Tu" present there but not "tu". The test() method even checks the case sensitivity. So the method resulted in false and displayed the result as shown in the output.
Live Demo
<html>
<body>
<p id="text">Tutorix is the best e-learning platform</p>
<p id="test"></p>
<script>
   var text = document.getElementById("text").innerHTML;
   document.getElementById("test").innerHTML = /tu/.test(text);
</script>
</body>
</html>
Tutorix is the best e-learning platform
false
How to use Collapse Component in ReactJS ? - GeeksforGeeks

22 Feb, 2021

Collapse Component adds a Collapse animation to a child element or component in which it vertically expands from the top of the child element. Material UI for React has this component available for us, and it is very easy to integrate. We can use the Collapse Component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command.
npm install @material-ui/core
Project Structure: 
Project Structure
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code. 
App.js
 

 
 










import React from 'react'; 
import FormControlLabel from '@material-ui/core/FormControlLabel'; 
import Paper from '@material-ui/core/Paper'; 
import Switch from '@material-ui/core/Switch'; 
import Collapse from '@material-ui/core/Collapse'; 
  
export default function App() { 
  
  const [isChecked, setIsChecked] = React.useState(false); 
  
  return ( 
    <div style={{ display: 'block', padding: 30 }}> 
      <h4>How to use Collapse Component in ReactJS?</h4> 
      <FormControlLabel 
        control={<Switch checked={isChecked} onChange={() => { 
          setIsChecked((prev) => !prev); 
        }} />} 
        label="Toggle me to see Collapse Effect"
      /> 
      <div style={{ display: 'flex' }}> 
        <Collapse in={isChecked}> 
          <Paper 
            elevation={5} 
            style={{ margin: 5 }} > 
            <svg style={{ width: 100, height: 100 }}> 
              <polygon points="0,80 45,00, 80,70"
                style={{ 
                  fill: 'orange', 
                  stroke: 'dimgrey', 
                  strokeWidth: 1, 
                }} /> 
            </svg> 
          </Paper> 
        </Collapse> 
      </div> 
    </div> 
  ); 
}






Step to Run Application: Run the application using the following command from the root directory of the project.
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
Reference: https://material-ui.com/components/transitions/#collapse

Material-UI


React-Questions


ReactJS


Web Technologies

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
React-Router Hooks
How to set background images in ReactJS ?
How to create a table in ReactJS ?
How to navigate on path by button click in react router ?
ReactJS useNavigate() Hook
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Convert a string to an integer in JavaScript
Java program to print duplicates from a list of integers

In order to find duplicates we can utilize the property of Set in Java that in Java duplicates are not allowed when going to be added in a Set.Add method of set returns true for the adding value which is not added previously to it while it would return false in case the adding value is already present in the Set.
For our agenda we would iterate out list or collection of integer and try to add each integer in a set of type integer.Now if integer gets added than this means that it is occurring for first time and not seems to be duplicate while if integer is not get added as Set add method returns false than it implies that it occurring again and is duplicate in the given list or collection.So for these type of integers which are duplicates we would add them in other set which would be our resultant duplicate integers.
 Live Demo
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
public class DuplicateIntegers {
   public static void main(String[] args) {
      ArrayList<Integer> arr = new ArrayList<>(Arrays.asList(1,2,3,4,45,55,3,32,22,22,55,1));
      HashSet<Integer> hCheckSet = new HashSet<>();
      HashSet<Integer> hTargetSet = new HashSet<>();
      for (Integer integer : arr) {
         if(!hCheckSet.add(integer)) {
            hTargetSet.add(integer);
         }
      }
      System.out.println("Duplicate integers in given list is/are " + hTargetSet);
   }
}
myCSV.csv file created with following text
Duplicate integers in given list is/are [1, 3, 55, 22]
GATE | GATE CS 2018 | Question 46 - GeeksforGeeks

01 Oct, 2021
Consider the following languages:
I. {ambncpdq ∣ m + p = n + q, where m, n, p, q ≥ 0}II. {ambncpdq ∣ m = n and p = q, where m, n, p, q ≥ 0}III. {ambncpdq ∣ m = n = p and p ≠ q, where m, n, p, q ≥ 0}IV. {ambncpdq ∣ mn = p + q, where m, n, p, q ≥ 0}
Which of the above languages are context-free?
(A) I and IV only(B) I and II only(C) II and III only(D) II and IV onlyAnswer: (B)Explanation: I. {ambncpdq ∣ m + p = n + q, where m, n, p, q ≥ 0}
m + p = n + q can also be written as m-n = q-p.
See the strings in given language : {ε ab, ad, bc, cd, abcd, abbc, aabb, aadd, acdd, bbcc, ccdd, aaabdd, aaabbd, bcccdd, aabcdd, .............}
Given language is Context free, so Push Down Automata can be designed for this. II. {ambncpdq ∣ m = n and p = q, where m, n, p, q ≥ 0}
m = n and p = q
See the strings in given language : { ε, ab, cd, abcd, aabbcd, abccdd, aaabbbccdd, ............}Definitely Context Free, hence PDA can be designed for this. 
III. m=n=p and p ≠ q. Not Context free.
IV. mn = p+q, Not Context free.
Option (B) is Correct.
YouTubeGeeksforGeeks GATE Computer Science16.2K subscribersGATE PYQ's on Grammars with Praddyumn Shukla | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0039:00 / 1:02:45•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=zAzS1PzU0NQ" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
Quiz of this Question
GATE CS 2018
GATE-GATE CS 2018
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2019 | Question 27
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2017 (Set 2) | Question 42
GATE | GATE CS 2010 | Question 24
GATE | GATE-CS-2000 | Question 43
GATE | GATE CS 2021 | Set 1 | Question 47
Playit

span#mySpan {  background-color:red;  display:inline;}
Largest Merge of Two Strings in C++

Let us suppose we have two strings 'a' and 'b' and a string 'merge'. The task is to fill the string 'merge' with the characters from 'a' and 'b' in such a way that,
If the string 'a' is non-empty, then remove the first character from the string 'a' and copy it into string 'merge'.
If the string 'b' is non-empty, then remove the first character from the string 'b' and copy it into string 'merge'.
If the strings 'a' and 'b' are non-empty, then remove the first characters from string 'a' and copy it into string 'merge' and then remove the first character (if any) from string 'b' and copy it into the string 'merge'.
Remove the characters from both the strings lexicographically, which means, if string 'a' is greater than string 'b', then remove the character from string 'a' and then string 'b'.
Return the string 'merge'.
For Example
Input-1:
a = “bacaa”
b = “abcaa”
b = “abcaa”
Output:
babcacaaaa
Explanation:
Since the given string 'a' is lexicographically greater than the string 'b', we will extract the first character from string 'a', i.e., “b” and then from string 'b'. After extracting, the string will be “babcacaaaa”.
The recursive approach to solve this problem is that we will extract each character of string 'a' and string 'b' and will check if the characters of string 'a' are lexicographically greater than the other string and finally concatenate to string 'merge'.
We will find the substring of each character after a number of positions and concatenate into 'merge' if it is lexicographically greater than the other string.
Take two input strings 'a' and 'b'.
A recursive string function concatenateLargest(string a, string b) takes two strings as the input and returns the largest string after concatenation, i.e., (string 'a' + string 'b').
If both the strings are empty, then return string 'a' + string 'b'.
If string 'a' is less than or equal to string 'b', then extract the first character and call the function recursively for other characters.
If string 'b' is less than or equal to string 'b', then extract the first character and call the function recursively for other characters.
Return the concatenated string.
Live Demo
#include <bits/stdc++.h>
using namespace std;
string concatenateLargest(string a, string b) {
   if (a.size() == 0 or b.size() == 0) {
      return (a + b);
   }
   if (a <= b)
      return b[0] + concatenateLargest(a, b.substr(1));
   else
      return a[0] + concatenateLargest(a.substr(1), b);
}
int main() {
   string a = "bacaa";
   string b = "abcaa";
   cout << concatenateLargest(a, b) << endl;
   return 0;
}
Running the above code will generate the output as,
bacabcaaaa
bacabcaaaa
The two strings “bacaa” and “abcaa” will become “bacabcaaaa” after merging according to the given problem.
VBScript LTrim Function

The Ltrim Function removes the blank spaces that are there on the left side of the string.
LTrim(String)

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         var = "Microsoft VBScript"
         document.write("After Ltrim : " & LTrim(var) & "<br />")

      </script>
   </body>
</html>
When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −
After Ltrim : Microsoft VBScript


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
DAX Date & Time - TIME function

Converts hours, minutes, and seconds given as numbers to a time in datetime format.
TIME (<hour>, <minute>, <second>) 

hour
A number from 0 to 23 representing the hour.
Any value greater than 23 will be divided by 24 and the remainder will be treated as the hour value.
minute
A number from 0 to 59 representing the minute.
Any value greater than 59 will be converted to hours and minutes.
second
A number from 0 to 59 representing the second.
Any value greater than 59 will be converted to hours, minutes, and seconds.
Returns the specified time in datetime format.
DAX works with date and time values in datetime format. Numbers in other formats are implicitly converted when you use a date/time value in a DAX function.
DAX TIME function takes the integers that are input as parameters and generates the corresponding time. The TIME function is most useful in situations where the hour, minute, and second are supplied by DAX formulas.
Time values are a portion of a date value, and in the serial number system are represented by a decimal number. Hence, the datetime value 12:00 PM is equivalent to 0.5, because it is half of a day. You can use DAX TIME function in conjunction with other DAX functions to convert the numbers to a format that can be recognized as a time.
= TIME (2,90,30) returns 12/30/1899 3:30:30 AM. 
= TIME (12, 30, 0) returns 12/30/1899 12:30:00 PM 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
What are the scope rules to functions in C programming?

Local scope specifies that variables defined within the block are visible only in that block and invisible outside the block.
Global scope specifies that variables defined outside the block are visible up to end of the program.
#include<stdio.h>
int r= 50; /* global area */
main (){
   int p = 30;
   printf (“p=%d, r=%d” p,r);
   fun ();
}
fun (){
   printf (“r=%d”,r);
}
p =30, r = 50
r = 50
A Function is a block of statements that performs a particular task.
A Function is a block of statements that performs a particular task.
Variables that are declared within the body of a function are called local variables
Variables that are declared within the body of a function are called local variables
These variables only exist inside the specific function that creates them. They are unknown to other functions and to the main functions also
These variables only exist inside the specific function that creates them. They are unknown to other functions and to the main functions also
The existence of local variables ends when the function completes its specific task and returns to the calling point.
The existence of local variables ends when the function completes its specific task and returns to the calling point.
#include<stdio.h>
main (){
   int a=10, b = 20;
   printf ("before swapping a=%d, b=%d", a,b);
   swap (a,b);
   printf ("after swapping a=%d, b=%d", a,b);
}
swap (int a, int b){
   int c;
   c=a;
   a=b;
   b=c;
}
Before swapping a=10, b=20
After swapping a = 10, b=20
Variables declared outside the body of a function are called global variables. These variables are accessible by any of the functions.
#include<stdio.h>
int a=10, b = 20;
main(){
   printf ("before swapping a=%d, b=%d", a,b);
   swap ();
   printf ("after swapping a=%d, b=%d", a,b);
}
swap (){
   int c;
   c=a;
   a=b;
   b=c;
}
Before swapping a = 10, b =20
After swapping a = 20, b = 10
VB.Net - GoTo Statement

The GoTo statement transfers control unconditionally to a specified line in a procedure.
The syntax for the GoTo statement is −
GoTo label

Module loops
   Sub Main()
      ' local variable definition 
      Dim a As Integer = 10
Line1:
      Do
         If (a = 15) Then
            ' skip the iteration '
            a = a + 1
            GoTo Line1
         End If
         Console.WriteLine("value of a: {0}", a)
         a = a + 1
      Loop While (a < 20)
      Console.ReadLine()
   End Sub
End Module
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19


    63 Lectures 
     4 hours 

 Frahaan Hussain

    103 Lectures 
     12 hours 

 Arnold Higuit

    60 Lectures 
     9.5 hours 

 Arnold Higuit

    97 Lectures 
     9 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page
partx - Unix, Linux Command

partx  - tell the Linux kernel about the presence and numbering of on-disk partitions
partx [-a|-d|-s|-u] [-t TYPE] [-n M:N] [-] disk
partx [-a|-d|-s|-u] [-t TYPE] partition [disk] 
Given a device or disk-image, partx tries to parse the partition table and list its contents. Itoptionally adds or removes partitions.
The disk argument is optional when apartitionargument is provided. To force scanning a partition as if it were a whole disk(for example to list nested subpartitions), use the argument "-". For example:

partx --show - /dev/sda3
The partx is not an fdisk program-- adding and removing partitions does not change the disk, it justtells the kernel about the presence and numbering of on-diskpartitions.
[M] Specifies just one partition (e.g. --nr 3)

[M:] Specifies lower limit only (e.g. --nr 2:)

[:N] Specifies upper limit only (e.g. --nr :4)

[M:N] or [M-N] Specifies lower and upper limits (e.g. --nr 2:4)

Example-1:
To list partition of /dev/sda:
# partx --show /dev/sda3# partx --show --nr 3 /dev/sda# partx --show /dev/sda3 /dev/sda
output:
# partx --show /dev/sda5NR  START      END  SECTORS  SIZE NAME UUID 5 501760 41940991 41439232 19.8G# partx --show --nr 5 /dev/sdaNR  START      END  SECTORS  SIZE NAME UUID 5 501760 41940991 41439232 19.8G# partx --show /dev/sda5 /dev/sdaNR  START      END  SECTORS  SIZE NAME UUID 5 501760 41940991 41439232 19.8G

Example-2:
Lists all subpartitions on /dev/sdb3 (the device is used as whole-disk):
# partx --show - /dev/sdb
output:
#  partx --show - /dev/sdaNR  START      END  SECTORS  SIZE NAME UUID 1   2048   499711   497664  243M 2 501758 41940991 41439234 19.8G 5 501760 41940991 41439232 19.8G
Example-3:
Prints the start sector of partition 5 on /dev/sdb without header:
# partx -o START -g --nr 5 /dev/sdb
output:
501760 
Example-4:
Lists the length in sectors and human-readable size of partition 5 on /dev/sda:
# partx -o SECTORS,SIZE /dev/sda5 /dev/sda
output: 
 SECTORS  SIZE41439232 19.8G
Example-5:
 Lists all the partition of disk /dev/sda:
# partx -l /dev/sda
output:
# 1:      2048-   499711 (   497664 sectors,    254 MB)# 2:    501758- 41940991 ( 41439234 sectors,  21216 MB)# 5:    501760- 41940991 ( 41439232 sectors,  21216 MB)
Example-6:
Adds all available partitions from 3 to 5 (inclusive) on /dev/sdd:
# partx --add --nr 3:5 /dev/sdd
output:
no output on screen after command execution, see partitions list.
Example-6:
Removes the last partition on /dev/sdd:
# partx -d --nr :-1 /dev/sdd
no output on screen after command execution, see partitions list.

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
HTML | <select> autocomplete Attribute - GeeksforGeeks

24 Apr, 2020
The HTML <select> autocomplete attribute is used to specify that the form has autocompleted on or off. When the autocomplete attribute is set to on the browser will automatically complete the values based on which the user entered before.
Syntax:
<select autocomplete="on | off"> 
Attribute Values:
on: It is the default value. When the autocomplete attribute is set to on the browser will automatically complete the values based on which the user entered before.
off: The user should have entered the values of each field for every use. The browser should not autocomplete entries.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML select autocomplete Attribute    </title></head>  <body style="text-align:center">      <h1 style="color: green;">        GeeksforGeeks    </h1>          <h2>        HTML select autocomplete Attribute    </h2>          <select autocomplete="on">        <option value="binary">            Binary Search        </option>        <option value="linear">            Linear Search        </option>        <option value="interpolation">            Interpolation Search        </option>    </select></body>  </html>
Output:
Supported Browsers: The browsers supported by HTML <select> autocomplete attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Design a web page using HTML and CSS
How to position a div at the bottom of its container using CSS?
How to create an HTML button that acts like a link?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Python - Itertools.Combinations_with_replacement() - GeeksforGeeks

13 Jul, 2021
Itertools in Python refers to module provided in Python for the creation of iterators which helps in efficient looping, time and space efficiency as well. Itertools helps us to solve complex problems easily and efficiently. There are in general 3 types of iterators.Different types of iterators provided by this module are:  
Combinatoric Generators  
Infinite Iterators  
Terminating Iterators  
Note: For more information, refer to Python Itertools 
Itertools.Combinations_with_replacement() lies in the Combinatoric Generator subtype of itertools. Combinatoric generators refer to those iterators which deal with the different arrangements possible for an iterator. Here the elements are referred with there index value and not by there value or type.How to use Itertools.Combinations_with_replacement() function? As understood by name “combinations” means all the possible subsets or arrangements of the iterator and the word “combinations_with_replacement” means all the possible arrangements or subsets that allow an element to repeat in a subset. This function takes ‘r’ as input here ‘r’ represents the size of different combinations that are possible. All the combinations with repetition of elements are emitted and are of length ‘r’ and ‘r’ is a necessary argument here.Example 1:-  
Python3
from itertools import combinations_with_replacement  a ="GEeks" l = list(combinations_with_replacement(a, 2))print("COMBINATIONS WITH REPLACEMENTS OF STRING GEeks OF SIZE 2.")print(l)
Output:- 
COMBINATIONS WITH REPLACEMENTS OF STRING GEeks OF SIZE 2. [(‘G’, ‘G’), (‘G’, ‘E’), (‘G’, ‘e’), (‘G’, ‘k’), (‘G’, ‘s’), (‘E’, ‘E’), (‘E’, ‘e’), (‘E’, ‘k’), (‘E’, ‘s’), (‘e’, ‘e’), (‘e’, ‘k’), (‘e’, ‘s’), (‘k’, ‘k’), (‘k’, ‘s’), (‘s’, ‘s’)]
Example 2:-  
Python3
from itertools import combinations_with_replacement          print ("All the combination of List in sorted order(with replacement) is:")  print(list(combinations_with_replacement('D.P.S.', 2)))  print()    print ("All the combination of list in sorted order(with replacement) is:")  print(list(combinations_with_replacement(range(1, 5), 2)))
Output:- 
All the combination of List in sorted order(without replacement) is: [(‘D’, ‘D’), (‘D’, ‘.’), (‘D’, ‘P’), (‘D’, ‘.’), (‘D’, ‘S’), (‘D’, ‘.’), (‘.’, ‘.’), (‘.’, ‘P’), (‘.’, ‘.’), (‘.’, ‘S’), (‘.’, ‘.’), (‘P’, ‘P’), (‘P’, ‘.’), (‘P’, ‘S’), (‘P’, ‘.’), (‘.’, ‘.’), (‘.’, ‘S’), (‘.’, ‘.’), (‘S’, ‘S’), (‘S’, ‘.’), (‘.’, ‘.’)]All the combination of list in sorted order(with replacement) is: [(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)]
 
sagar0719kumar
Picked
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python Classes and Objects
Create a directory in Python
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Python | Get unique values from a list
In-place Move Zeros to End of List in Python

Suppose we have a list of numbers nums, we have to put all the zeros to the end of the list by
updating the list in-place. And the relative ordering of other elements should not be changed.
We have to try to solve this in O(1) additional space.
So, if the input is like [2,0,1,4,0,5,6,4,0,1,7], then the output will be [2, 1, 4, 5, 6, 4, 1, 7, 0, 0, 0]
To solve this, we will follow these steps −
if size of L is same as 0, thenreturn a blank list
return a blank list
k := 0
for i in range 0 to size of L, doif L[i] is not same as 0, thenL[k] := L[i]k := k + 1
if L[i] is not same as 0, thenL[k] := L[i]k := k + 1
L[k] := L[i]
k := k + 1
for j in range k to size of L, doL[j] := 0
L[j] := 0
return L
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, L):
      if len(L) == 0:
         return []
         k = 0
         for i in range(len(L)):
            if L[i] != 0:
               L[k] = L[i]
               k+=1
         for j in range(k,len(L)):
            L[j] = 0
         return L
ob = Solution()
L = [2,0,1,4,0,5,6,4,0,1,7]
print(ob.solve(L))
[2,0,1,4,0,5,6,4,0,1,7]
[2, 1, 4, 5, 6, 4, 1, 7, 0, 0, 0]
AngularJS End to End (E2E) Testing Protractor | Installation and Setup - GeeksforGeeks

27 Nov, 2020
Protractor is an end-to-end test framework developed for Angular and AngularJS applications. It runs tests against the application interacting with it as a real user would, running in a real browser.
Features:
Tests using browser: Protractor uses native events and browser-specific drivers to interact with the application.
Build for Angular: Protractor is built for Angular and thus the support is amazing.
Automatic Waiting: You no longer need to add waits and sleeps to your test. Protractor automatically executes the next step in your test the moment the webpage finishes pending tasks, so you don’t have to be waiting for your test and webpage to sync.
Installation: 
1. Protractor can be installed globally over NodeJS using the command given below:
// For Windows
npm install -g protractor

// For Linux
sudo npm install -g protractor
Note: For users in Ubuntu, you need to add sudo to all the given commands for permission.
2. Now to check if the installation was successful let’s check the version of the protractor using the command given below:
protractor --version
3. The above screenshot says the version is 7.0.0 which means the installation was successful.
Setup: Now we have two commands available to us after the installation which are protractor and webdriver-manager. The webdriver-manager is a helper tool to easily get an instance of a Selenium Server running. There are two steps to be followed now:
4. Updating the binaries: We can update the necessary binaries using the below command.
// For Windows
webdriver-manager update

// For Linux
sudo webdriver-manager update
5. Starting the server: After this, we can run Selenium Server using the below command.
// For Windows
webdriver-manager start

// For Linux
sudo webdriver-manager start
6. After this, you can access the server at http://localhost:4444/wd/hub. 
AngularJS-Misc
AngularJS
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Calendar Component
Angular PrimeNG Messages Component
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
Finding the largest and smallest number in an unsorted array of integers in JavaScript

We are required to write a JavaScript function that takes in an array of Numbers. The function should, in linear time and constant space, find the largest and smallest numbers that exist in the array. The function should return an object that contains the min and max numbers.
Following is the code −
const arr = [112, 24, 31, 44, 101, 203, 33, 56];
const findMaxMin = (arr) => {
   let max = arr[0];
   let min = arr[0];
   for(let i = 0; i < arr.length; i++) {
      if(arr[i] > max) {
         max = arr[i];
      }
      else if (arr[i] < min) {
         min = arr[i];
      }
   };
   return {
      min, max
   };
};
console.log(findMaxMin(arr));
Following is the output on console −
{ min: 24, max: 203 }
How to clone or copy a list in Python?

In Python, assignment operator doesn’t create a new object, rather it gives another name to already existing object. This can be verified by id() function
>>> L1 = [1,2,3,4]
>>> L2 = L1
>>> id(L1)
185117137928
>>> id(L2)
185117137928
To actually copy a list, following methods can be used.
Slice operator: Two operands of slice operator are index of start and end of slice. If not explicitly used, both default to start end of sequence. We can take advantage of this feature
>>> L1 = [1,2,3,4]
>>> L2 = L1[:]
>>> L1
[1, 2, 3, 4]
>>> L2
[1, 2, 3, 4]
>>> id(L1)
185117025160
>>> id(L2)
185117171592
Another method is to use built-in list() method
>>> L1 =[ 1,2,3,4]
>>> L2 = list(L1)
>>> L1
[1, 2, 3, 4]
>>> L2
[1, 2, 3, 4]
>>> id(L1)
185117295816
>>> id(L2)
185117209352
The copy module of Python’s standard library contains functions for shallow and deep copy of objects. While deep copy is nested copying, in shallow copy, inner list copied by reference only.
>>> import copy
>>> L1 = [1,2,3,4]
>>> L2 = copy.copy(L1)
>>> L1
[1, 2, 3, 4]
>>> L2
[1, 2, 3, 4]
>>> id(L1)
185117025160
>>> id(L2)
185117295880
>>> L3=copy.deepcopy(L1)
>>> L3
[1, 2, 3, 4]
>>> id(L3)
185117304328
Why is the dot product of orthogonal vectors zero? | by Aerin Kim | Towards Data Science

It is “by definition”. Two non-zero vectors are said to be orthogonal when (if and only if) their dot product is zero.
Ok. But why did we define the orthogonality this way?
The dot product of two vectors is defined algebraically:
Yet, there is also a geometric definition of the dot product:
a • b = ‖a‖ * ‖b‖ * cosø
which is multiplying the length of the first vector with the length of the second vector with the cosine of the angle between the two vectors.
And the angle between the two perpendicular vectors is 90°.
When we substitute ø with 90° (cos 90°=0), `a•b` becomes zero.
I want more than just a definition. Show me something real?
Ok... then let me show you how those two definitions (geometric and algebraic) agree with each other through the Pythagorean theorem.
Below is a basic recap of the vector norm. They will be used in expanding Pythagoras theorem to n-dimensions.
Now, consider two vectors [-1, 2] and [4, 2].
Algebraically, [-1, 2] • [4, 2] = -4 + 4 = 0.
Applying the length formula 2 to the Pythagorean theorem:
Geometrically, you can see they are perpendicular as well.
The geometric definition matches with the algebraic definition!
A Pop Quiz:
Orthogonal vectors are linearly independent. This sound obvious- but can you prove it mathematically?
Hint: You can use two definitions. 1) The algebraic definition of orthogonality2) The definition of linear Independence: The vectors {V1, V2, ... , Vn} are linearly independent if the equation a1 * V1 + a2 * V2 + ... + an * Vn = 0 can only be satisfied by ai = 0 for all i.