code-rag-bench/online-tutorials huggingface dataset:
Avoid wrapping flex-items in Bootstrap

Use the flex-nowrap class in Bootstrap 4 to avoid wrapping the flex items.
Here you can see the difference between wrap and nowrap −
Above the flex-items are not wrapped. This is achieved using the flex-nowrap class in Bootstrap 4 −
<div class="d-flex flex-nowrap bg-primary">
  <div class="p-2 border">One</div>
  <div class="p-2 border">Two</div>
  <div class="p-2 border">Three</div>
  <div class="p-2 border">Four</div>
  <div class="p-2 border">Five</div>
  <div class="p-2 border">Six</div>
  <div class="p-2 border">Seven</div>
  <div class="p-2 border">Eight</div>
  <div class="p-2 border">Nine</div>
</div>
The following is an example to avoid wrapping flex items −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <div class="container mt-3">
    <h3>FLEX WRAP AND NOWRAP</h3>
    <p>Flex items will wrap</p>
    <div class="d-flex flex-wrap bg-primary">
      <div class="p-2 border">One</div>
      <div class="p-2 border">Two</div>
      <div class="p-2 border">Three</div>
      <div class="p-2 border">Four</div>
      <div class="p-2 border">Five</div>
      <div class="p-2 border">Six</div>
      <div class="p-2 border">Seven</div>
      <div class="p-2 border">Eight</div>
      <div class="p-2 border">Nine</div>
    </div><br>
    <p>Flex items won't wrap</p>
    <div class="d-flex flex-nowrap bg-primary">
      <div class="p-2 border">One</div>
      <div class="p-2 border">Two</div>
      <div class="p-2 border">Three</div>
      <div class="p-2 border">Four</div>
      <div class="p-2 border">Five</div>
      <div class="p-2 border">Six</div>
      <div class="p-2 border">Seven</div>
      <div class="p-2 border">Eight</div>
      <div class="p-2 border">Nine</div>
    </div><br>
  </div>
</body>
</html>
How to get the count of a specific value in a column with MySQL?

Let us first create a table −
mysql> create table DemoTable
   (
      Id int,
      Name varchar(100)
   );
Query OK, 0 rows affected (1.40 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100,'John');
Query OK, 1 row affected (0.44 sec)
mysql> insert into DemoTable values(101,'Chris');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values(102,'Chris');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values(103,'Chris');
Query OK, 1 row affected (1.05 sec)
mysql> insert into DemoTable values(104,'David');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values(105,'Chris');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values(106,'Carol');
Query OK, 1 row affected (0.24 sec)
mysql> insert into DemoTable values(107,'Bob');
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-------+
| Id   | Name  |
+------+-------+
| 100  | John  |
| 101  | Chris |
| 102  | Chris |
| 103  | Chris |
| 104  | David |
| 105  | Chris |
| 106  | Carol |
| 107  | Bob   |
+------+-------+
8 rows in set (0.00 sec)
Following is the query to get the count of a specific value in a column i.e. ‘Chris’ here −
mysql> select count(*) from DemoTable where Name='Chris';
This will produce the following output −
+----------+
| count(*) |
+----------+
| 4        |
+----------+
1 row in set (0.00 sec)
GATE | GATE CS 2013 | Question 31 - GeeksforGeeks

31 May, 2021
Consider the following function:
int unknown(int n) {    int i, j, k = 0;    for (i  = n/2; i <= n; i++)        for (j = 2; j <= n; j = j * 2)            k = k + n/2;    return k; }
(A)
(B)
(C)
(D)
(A) A(B) B(C) C(D) DAnswer: (B)Explanation: Here we have to tell the value of k returned not the time complexity.  
for (i  = n/2; i <= n; i++)
        for (j = 2; j <= n; j = j * 2)
            k = k + n/2;
    return k;
The outer loop runs n/2 times The inner loop runs logn times.(2^k = n => k = logn). Now looking at the value of k in inner loop, n is added to k, logn times as the inner loop is running logn times. Therefore total time complexity is inner multiplied with outer loop complexity which (n for outer and nlogn for inner) n*logn. 
Therefore the value of k after running the inner loop one time is  n^2logn.See http://geeksquiz.com/algorithms-analysis-of-algorithms-question-5/This solution is contributed by Parul Sharma.
Quiz of this Question
AbhinavPanse
GATE-CS-2013
GATE-GATE CS 2013
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2007 | Question 17
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE CS 1997 | Question 25
GATE | GATE CS 2019 | Question 37
How to remove first character from column name in R data frame?

To remove first character from column name in R data frame, we can use str_sub function of stringr package.
For Example, if we have a data frame called df that contains two columns say XID and XDV then we can remove X from both the column names by using the below mentioned command −
names(df)=str_sub(names(df),2)
Following snippet creates a sample data frame −
XColor<-sample(c("Green","Red","Blue"),20,replace=TRUE)
YScore<-sample(1:100,20)
df1<-data.frame(XColor,YScore)
df1
The following dataframe is created
  XColor YScore
1  Green   46
2  Red     80
3  Red     22
4  Green   21
5  Blue    54
6  Red     81
7  Blue    41
8  Red      4
9  Blue    63
10 Green   67
11 Green   71
12 Red     65
13 Red     79
14 Blue    58
15 Blue    76
16 Green   10
17 Red     60 
18 Red     16
19 Green   27
20 Red     74
To load stringr package and remove first character from column names in df1 on the above created data frame, add the following code to the above snippet −
XColor<-sample(c("Green","Red","Blue"),20,replace=TRUE)
YScore<-sample(1:100,20)
df1<-data.frame(XColor,YScore)
library(stringr)
names(df1)=str_sub(names(df1),2)
df1
If you execute all the above given snippets as a single program, it generates the following Output −
   Color Score
1  Green   46
2  Red     80
3  Red     22
4  Green   21
5  Blue    54
6  Red     81
7  Blue    41
8  Red      4
9  Blue    63
10 Green   67
11 Green   71
12 Red     65
13 Red     79
14 Blue    58
15 Blue    76
16 Green   10
17 Red     60
18 Red     16
19 Green   27
20 Red     74
Following snippet creates a sample data frame −
SStudents_ID<-c(200001:200020)
LLevel<-sample(c("First","Second","Third"),20,replace=TRUE)
df2<-data.frame(SStudents,LLevel)
df2
The following dataframe is created
SStudents LLevel
1  200001 First
2  200002 Third
3  200003 Third
4  200004 Second
5  200005 Second
6  200006 Second
7  200007 Second
8  200008 First
9  200009 Second
10 200010 Second
11 200011 First
12 200012 Third
13 200013 Second
14 200014 Second
15 200015 Second
16 200016 First
17 200017 First
18 200018 Third
19 200019 Third
20 200020 Second
To remove first character from column names in df2 on the above created data frame, add the following code to the above snippet −
SStudents_ID<-c(200001:200020)
LLevel<-sample(c("First","Second","Third"),20,replace=TRUE)
df2<-data.frame(SStudents,LLevel)
names(df2)=str_sub(names(df2),2)
df2
If you execute all the above given snippets as a single program, it generates the following Output −
  Students Level
1  200001 First
2  200002 Third
3  200003 Third
4  200004 Second
5  200005 Second
6  200006 Second
7  200007 Second
8  200008 First
9  200009 Second
10 200010 Second
11 200011 First
12 200012 Third
13 200013 Second
14 200014 Second
15 200015 Second
16 200016 First
17 200017 First
18 200018 Third
19 200019 Third
20 200020 Second
How to create an HTML document which uses aside element ? - GeeksforGeeks

15 Oct, 2020
The <aside> tag is used to describe the main object of the web page in a shorter way like a highlighter. It basically identifies the content that is related to the primary content of the web page but does not constitute the main intent of the primary page. The <aside> tag contains mainly author information, links, related content and so on.
The <aside> tag makes easy to design the page and it enhances clarity of HTML document. It let us easily recognize the main text and subordinate text. In both the time <div> and <aside> need CSS to specific design. The <aside> tag supports Global attributes and Event attributes in HTML.
Syntax:
<aside>
    <h3>Contents...</h3>
    <p>Contents...</p>
</aside>

Example 1:
HTML
<!DOCTYPE html><html>  <head>    <style>        h1 {            font-size: 40px;            color: #090;            font-weight: bold;        }          p {            font-size: 20px;            margin: 20px 0;        }    </style></head>  <body>    <aside>        <h1>GeeksforGeeks</h1>          <p>A computer science portal for geeks</p>      </aside></body>  </html>
Output:
Example 2:
HTML
<!DOCTYPE html><html>  <head>    <style>        .gfg {            font-size: 40px;            color: #090;            font-weight: bold;            text-align: center;            margin-bottom: 20px;        }          article {            width: 50%;            float: left;            padding: 10px;            float: left;        }          aside {            float: right;            width: 40%;            float: right;            background-color: green;            color: white;            padding: 5px;            margin: 10px;            height: 100px;        }    </style></head>  <body>    <div class="gfg">        GeeksforGeeks    </div>      <article>        <h1>Article Title</h1>          <p>            Aside tag is use to display            important information            about the primary page.        </p>      </article>      <aside>        <h1>Aside Tag Example</h1>          <p>Aside tag content. . .</p>      </aside></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between CSS and CSS3
Borders in bootstrap with examples
How to create fade-in effect on page load using CSS ?
Simple Tic-Tac-Toe Game using JavaScript
How to style a checkbox using CSS?
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
HTML | <img> align Attribute
How to Extract Frames From a Video in MATLAB? - GeeksforGeeks

20 Aug, 2020
Let us see how to extract frames from a video in MATLAB.
Approach :
Import the video which is to be converted into frames into the current matlab environment.Extract the total number of frames in the video.Make an empty directory named frames before the execution.Run a for loop and start extracting the frames into the directory.
Import the video which is to be converted into frames into the current matlab environment.
Extract the total number of frames in the video.
Make an empty directory named frames before the execution.
Run a for loop and start extracting the frames into the directory.
In our demonstration, we shall consider the following video :
% import the video fileobj = VideoReader('org.mp4');vid = read(obj);   % read the total number of framesframes = obj.NumberOfFrames;  % file format of the frames to be saved inST ='.jpg';  % reading and writing the frames for x = 1 : frames      % converting integer to string    Sx = num2str(x);      % concatenating 2 strings    Strc = strcat(Sx, ST);    Vid = vid(:, :, :, x);    cd frames      % exporting the frames    imwrite(Vid, Strc);    cd ..  end
Output :The frames directory will look something like this :
Images saved in the frames folder
MATLAB
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Reinforcement learning
Decision Tree
Decision Tree Introduction with example
System Design Tutorial
Copying Files to and from Docker Containers
Python | Decision tree implementation
ML | Underfitting and Overfitting
Clustering in Machine Learning
Docker - COPY Instruction
Duration from(TemporalUnit) method in Java with Examples - GeeksforGeeks

26 Nov, 2018
The from(TemporalUnit) method of Duration Class in java.time package is used to get a duration from the amount passed as the first parameter in the TemporalUnit. The TemporalUnit can be DAYS, HOURS, etc.
Syntax:
public static Duration from(TemporalUnit amount)

Parameters: This method accepts a parameter amount which is amount from which the Duration is to be found, passed as the TemporalUnit.
Return Value: This method returns a Duration representing the time of specified amount.
Exception: This method throws following unit:
ArithmeticException: if numeric overflow occurs.
DateTimeException: if unable to convert to a Duration
Below examples illustrate the Duration.from() method:
Example 1:
// Java code to illustrate from() method  import java.time.Duration;  public class GFG {    public static void main(String[] args)    {          // Get the amount        Duration duration = Duration.ofDays(5);          // Duration using from() method        Duration duration1 = Duration.from(duration);          System.out.println(duration1.getSeconds());    }}
432000

Example 2:
// Java code to illustrate from() method  import java.time.Duration;  public class GFG {    public static void main(String[] args)    {          // Get the amount        Duration duration = Duration.ofHours(5);          // Duration using from() method        Duration duration1 = Duration.from(duration);          System.out.println(duration1.getSeconds());    }}
18000

Reference: Oracle Doc
Java-Duration
Java-Functions
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Python - String Repetition and spacing in List - GeeksforGeeks

25 Oct, 2021
Sometimes while working with Python, we can have a problem in which we need to perform the repetition of each string in list and also attach a deliminator to each occurrence. This kind of problem can occur in day-day programming. Lets discuss certain ways in which this task can be performed.Method #1 : Using loop This task can be performed in brute force way using loop. In this, we iterate the list and perform string addition and multiplication while iteration using suitable operators. 
Python3
# Python3 code to demonstrate working of# String Repetition and spacing in List# Using loop # initializing listtest_list = ['gfg', 'is', 'best'] # printing original listprint("The original list is : " + str(test_list)) # initializing delimdelim = '-' # initializing KK = 3 # String Repetition and spacing in List# Using loopres = []for sub in test_list:    res.append((sub + delim) * K)     # printing resultprint("List after performing operations : " + str(res))
The original list is : ['gfg', 'is', 'best']
List after performing operations : ['gfg-gfg-gfg-', 'is-is-is-', 'best-best-best-']
 
 Method #2 : Using join() + list comprehension The combination of above functionalities can also be used to perform this task. In this, we perform the task of attaching delim using join() and list comprehension performs the task of repetition. Avoids trailing delim. 
Python3
# Python3 code to demonstrate working of# String Repetition and spacing in List# Using join() + list comprehension # initializing listtest_list = ['gfg', 'is', 'best'] # printing original listprint("The original list is : " + str(test_list)) # initializing delimdelim = '-' # initializing KK = 3 # String Repetition and spacing in List# Using join() + list comprehensionres = []for sub in test_list:    res.append(delim.join([sub for _ in range(K)]))     # printing resultprint("List after performing operations : " + str(res))
The original list is : ['gfg', 'is', 'best']
List after performing operations : ['gfg-gfg-gfg', 'is-is-is', 'best-best-best']
 
ruhelaa48
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 ?
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
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?
Python | Numpy.broadcast_arrays() method - GeeksforGeeks

17 Sep, 2019
With the help of Numpy.broadcast_arrays() method, we can get the one broadcasted array with the help of two or more arrays by using Numpy.broadcast_arrays() method.
Syntax : Numpy.broadcast_arrays()
Return : Return the broadcasted array using numpy.
Example #1 :In this example we can see that by using Numpy.broadcast_arrays() method, we are able to get the broadcasted array using two or more numpy arrays.
# import numpyimport numpy as np  # using Numpy.broadcast_arrays() methodgfg1 = np.array([[1, 2]])gfg2 = np.array([[3], [4]])  print(np.broadcast_arrays(gfg1, gfg2))
Output :
[array([[1, 2],[1, 2]]), array([[3, 3],[4, 4]])]
Example #2 :
# import numpyimport numpy as np  # using Numpy.broadcast_arrays() methodgfg1 = np.array([[1, 2], [6, 7]])gfg2 = np.array([[3, 5], [4, 8]])  print(np.broadcast_arrays(gfg1, gfg2))
Output :
[array([[1, 2],[6, 7]]), array([[3, 5],[4, 8]])]
Python numpy-Basics
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?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
TypeScript | Array join() Method - GeeksforGeeks

18 Jun, 2020
The Array.join() is an inbuilt TypeScript function which is used to joins all the elements of an array into a string. Syntax:
array.join(separator)

Parameter: This method accept a single parameter as mentioned above and described below:
separator : This parameter is the a string to separate each element of the array.
Return Value: This method returns the string after joining all the array elements. Below examples illustrate the Array join() method in TypeScript.
Example 1: 
JavaScript
<script>    // Driver code    var arr = [ 11, 89, 23, 7, 98 ];       // use of join() method     var str = arr.join(", ")           // printing element    console.log("String : " + str);</script>
Output: 
String : 11, 89, 23, 7, 98


Example 2: 
JavaScript
<script>    // Driver code    var arr = [ 'a','b','c','a','e' ];       // use of join() method     var val = arr.join(" ")    var val1 = arr.join(" + ")           // printing element    console.log(val);    console.log(val1);</script>
Output: 
a b c a e
a + b + c + a + e


TypeScript
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
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 append HTML code to a div using JavaScript ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
ML | Determine the optimal value of K in K-Means Clustering - GeeksforGeeks

12 Oct, 2021
Prerequisite: K-Means Clustering | IntroductionThere is a popular method known as elbow method which is used to determine the optimal value of K to perform the K-Means Clustering Algorithm. The basic idea behind this method is that it plots the various values of cost with changing k. As the value of K increases, there will be fewer elements in the cluster. So average distortion will decrease. The lesser number of elements means closer to the centroid. So, the point where this distortion declines the most is the elbow point. 
3 clusters are forming
In the above figure, its clearly observed that the distribution of points are forming 3 clusters. Now, let’s see the plot for the squared error(Cost) for different values of K.  
Elbow is forming at K=3
Clearly the elbow is forming at K=3. So the optimal value will be 3 for performing K-Means.Another Example with 4 clusters.  
4-clusters
Corresponding Cost graph-  
Elbow is forming at K=4
In this case the optimal value for k would be 4. (Observable from the scattered points).Below is the Python implementation:  
Python3
import matplotlib.pyplot as pltfrom matplotlib import stylefrom sklearn.cluster import KMeansfrom sklearn.datasets.samples_generator import make_blobs style.use("fivethirtyeight") # make_blobs() is used to generate sample points# around c centers (randomly chosen)X, y = make_blobs(n_samples = 100, centers = 4,                cluster_std = 1, n_features = 2)                 plt.scatter(X[:, 0], X[:, 1], s = 30, color ='b') # label the axesplt.xlabel('X')plt.ylabel('Y') plt.show()plt.clf() # clear the figure
Output:  
 
Python3
cost =[]for i in range(1, 11):    KM = KMeans(n_clusters = i, max_iter = 500)    KM.fit(X)         # calculates squared error    # for the clustered points    cost.append(KM.inertia_)     # plot the cost against K valuesplt.plot(range(1, 11), cost, color ='g', linewidth ='3')plt.xlabel("Value of K")plt.ylabel("Squared Error (Cost)")plt.show() # clear the plot # the point of the elbow is the# most optimal value for choosing k
Output:  
 
surinderdawra388
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Decision Tree
Activation functions in Neural Networks
Decision Tree Introduction with example
Introduction to Recurrent Neural Network
Support Vector Machine Algorithm
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
C# | Check if an array is synchronized (thread safe) or not - GeeksforGeeks

01 Feb, 2019
Array.IsSynchronized Property is used to get a value which indicates whether access to the Array is synchronized (thread-safe) or not.
Syntax:
public bool IsSynchronized { get; }
Property Value: This property always returns false for all arrays.
Below programs illustrate the use of above-discussed property:
Example 1:
// C# program to illustrate// IsSynchronized Property of// Array classusing System;namespace geeksforgeeks {  class GFG {      // Main Method    public static void Main()    {          // The array with dimensions          // specified 4 row and 2 column.         int[, ] arr = new int[4, 2] {{1, 2 }, {3, 4},                                              {5, 6 }, {7, 8}};          // Here we check whether the        // array is synchronized (thread safe)        // or not        Console.WriteLine("Result: " + arr.IsSynchronized);    }}}
Result: False

Example 2:
// C# program to illustrate// IsSynchronized Property of// Array classusing System;namespace geeksforgeeks {  class GFG {      // Main Method    public static void Main()    {          // declares an 1D Array of string.        string[] topic;          // allocating null to array        topic = new string[] { null };          // Here we check whether the        // array is synchronized (thread safe)        // or not        Console.WriteLine("Result: " + topic.IsSynchronized);    }}}
Result: False

Note:
Array implements the IsSynchronized property because it is needed by the System.Collections.ICollection interface.
Classes which uses the arrays can also implement their own synchronization using the SyncRoot property.
Enumerating through a collection is not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
Retrieving the value of this property is an O(1) operation.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.array.issynchronized?view=netframework-4.7.2
CSharp-Arrays
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Class and Object
C# | Constructors
C# | Replace() Method
Introduction to .NET Framework
Deque interface in Java

java.util.Deque interface is a subtype of java.util.Queue interface which supports insertion and removal of elements at both ends.
public interface Deque<E>
extends Queue<E>
The java.util.ArrayDeque class provides resizable-array and implements the Deque interface. Following are the important points about Array Deques −
Array deques have no capacity restrictions so they grow as necessary to support usage.
Array deques have no capacity restrictions so they grow as necessary to support usage.
They are not thread-safe; in the absence of external synchronization.
They are not thread-safe; in the absence of external synchronization.
They do not support concurrent access by multiple threads.
They do not support concurrent access by multiple threads.
Null elements are prohibited in the array deques.
Null elements are prohibited in the array deques.
They are faster than Stack and LinkedList.
They are faster than Stack and LinkedList.
This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces.
Following is the declaration for java.util.ArrayDeque class −
public class ArrayDeque<E>
extends AbstractCollection<E>
implements Deque<E>, Cloneable, Serializable
Here <E> represents an Element, which could be any class. For example, if you're building an array list of Integers then you'd initialize it as −
ArrayList<Integer> list = new ArrayList<Integer>();
import java.util.ArrayDeque;
import java.util.Deque;

public class Tester {
   public static void main(String[] args) {

      // create an empty array deque with an initial capacity
      Deque<Integer> deque = new ArrayDeque<Integer>(5);

      // use add() method to add elements in the deque
      deque.add(20);
      deque.add(30);
      deque.add(20);
      deque.add(30);
      deque.add(15);
      deque.add(22);
      deque.add(11);

      // let us print all the elements available in deque
      for (Integer number : deque) {
         System.out.println("Number = " + number);
      }

      // getFirst() will retrieve element at first position
      int first = deque.getFirst();
      System.out.println("Retrieved Element is = " + first);

      // getLast() will retrieve element at last position
      int last = deque.getLast();
      System.out.println("Retrieved Element is = " + last);
   }
}
Number = 20
Number = 30
Number = 20
Number = 30
Number = 15
Number = 22
Number = 11
Retrieved Element is = 20
Retrieved Element is = 11
Cyclically rotate an array by one | Practice | GeeksforGeeks

Given an array, rotate the array by one position in clock-wise direction.
 
Example 1:
Input:
N = 5
A[] = {1, 2, 3, 4, 5}
Output:
5 1 2 3 4
 
Example 2:
Input:
N = 8
A[] = {9, 8, 7, 6, 4, 2, 1, 3}
Output:
3 9 8 7 6 4 2 1
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function rotate() which takes the array A[] and its size N as inputs and modify the array.
 
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
 
Constraints:
1<=N<=105
0<=a[i]<=105
0
amreshpathak1 hour ago
Simple Solution:- 
 
public void rotate(int arr[], int n)   {       int temp = arr[arr.length - 1];       for(int i = arr.length-1;i>0;i--){           arr[i] = arr[i-1];       }       arr[0] = temp;   }
0
aryanraveshia126 hours ago
void rotate(int arr[], int n){   int temp = arr[n-1];   for(int i=1;i<=n;i++){       arr[n-i] = arr[n-i-1];   }   arr[0] = temp;}
0
georgepriji8 hours ago
//c,c++, java
int k = arr[n-1];   for(int i = n-2; i>=0; i--){       k = arr[i+1];       arr[i+1]=arr[i];       arr[i] = k;   }   arr[0] = k;
+1
shubhsahane12341 day ago
void rotate(int arr[], int n){   for(int i=0;i<n;i++){   int temp = arr[i];   arr[i] = arr[n-1];   arr[n-1] = temp;   }}
+1
rahulvishwas26021 day ago
int temp=arr[n-1];for(int i=n-1;i>0;i--){   arr[i]=arr[i-1];}arr[0]=temp;
0
ateebashway1712 days ago
void rotate(int arr[], int n){   for(int i=n-1; i>=1; i--){       int temp = arr[i];       arr[i] = arr[i-1];       arr[i-1] = temp;   }}
0
himanshusethin2 days ago
if(n>1){       int temp = arr[n-1];       for(int i =n-1;i>0;i--)           arr[i] = arr[i-1];       arr[0] = temp;   }
0
pramodchary242 days ago
public void rotate(int arr[], int n)   {       int temp1=arr[n-1];       int temp2=0;       for(int i=0; i<n; i++){           temp2=arr[i];           arr[i]=temp1;           temp1=temp2;       }   }
+1
harshscode5 days ago
  int t=a[n-1];  for(int i=n-1;i>0;i--)  a[i]=a[i-1];  a[0]=t;
-1
harshscode5 days ago
 for(int i=0;i<n;i++)  {      int t=a[i];      a[i]=a[n-1];      a[n-1]=t;  }
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Tryit Editor v3.7

Tryit: Display a none-breaking-space
How to create a frame inside a frame tkinter? - GeeksforGeeks

21 Jun, 2021
Prerequisite: Tkinter
It is very easy to create a basic frame using Tkinter, this article focuses on how another frame can be created within it. To create a basic frame the name of the parent window is given as the first parameter to the frame() function. Therefore, to add another frame within this frame, just the name of the first frame needs to given to the second frame as the parent window.
Optional values such as frame padding are give relative to the parent window. We can add multiple frames in this fashion using the same approach, by making the previous frame the parent of the current frame.
Approach:
Create Normal Tkinter Window
Create first frame normally
Create second frame
Take the first window as its parent window
Execute code
frame() is an inbuilt Tkinter method which helps realize our required functionality.
Syntax: frame(master)
Parameter:
master: parent window
highlightcolor: To set the color of the focus highlight when widget has to be focused.
bd: to set the border width in pixels.
bg: to set the normal background color.
cursor: to set the cursor used.
width: to set the width of the widget.
height: to set the height of the widget.
Program:
Python3
# Import Modulefrom tkinter import * # Create Tkinter Objectroot = Tk() # Set Geometryroot.geometry("400x400") # Frame 1frame1 = Frame(root,bg="black",width=500,height=300)frame1.pack() # Frame 2frame2 = Frame(frame1,bg="white",width=100,height=100)frame2.pack(pady=20,padx=20) # Execute Tkinterroot.mainloop()
 
 
Output:
 
 
anikakapoor
Picked
Python-tkinter
Python
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?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Selecting rows in pandas DataFrame based on conditions
Python | os.path.join() method
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
jQuery - scrollTop( ) Method

The scrollTop( ) method gets the scroll top offset of the first matched element.
This method works for both visible and hidden elements.
Here is the simple syntax to use this method −
selector.scrollTop( )

Here is the description of all the parameters used by this method −
NA
NA
Following is a simple example a simple showing the usage of this method −
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function(){
            $("div.demo").scrollTop( 200 );
				
            $("div.demo").mousemove(function () {
               var top = $("div.demo").scrollTop();
               $("#result").html("top offset: <span>" + top + "</span>.");
            });
				
         });
      </script>
		
      <style>
         div.demo {background:#CCCCCC none repeat scroll 0 0; border:3px 
            solid #666666; margin:5px; padding:5px; position:relative;
            width:200px; height:100px; overflow:auto;}
				
         div.result{margin:10px; width:100px; height:100px; 
            margin:5px; float:left; background-color:blue;}
				
         p { margin:10px; padding:5px; border:2px solid #666; 
            width:1000px; height:1000px;}
      </style>
   </head>
	
   <body>
      <div class = "demo"><p>Hello</p></div>
      <span>Scroll vertical button to see the result:</span>
      <div class = "result"><span id = "result"></span></div>
   </body>
</html>
This will produce following result −
Hello

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
How to work with document.forms in JavaScript?

Use the document.forms property in JavaScript to get the number of <form> tags in a document.
You can try to run the following code to implement document.forms property in JavaScript.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <h1>Employee Information</h1>
      <form>
         Name: <input type="text" name="name" value="Amit"><br>
         Subject: <input type="text" name="sub" value="Java">
      </form>
      <h1>Department Information</h1>
      <form>
         DepartmentID: <input type="text" name="dptid" value="D001"><br>
         Dept Name: <input type="text" name="dname" value="Marketing">
      </form>
      <script>
         var num = document.forms.length;
         document.write("<br>How many forms? "+num);
      </script>
   </body>
</html>
How to animate the colorbar in Matplotlib?

To animate the colorbar in matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure.
Create a new figure or activate an existing figure.
Add an '~.axes.Axes' to the figure as part of a subplot arrangement.
Add an '~.axes.Axes' to the figure as part of a subplot arrangement.
Instantiate Divider based on the pre-existing axes, i.e., ax object and return a new axis locator for the specified cell.
Instantiate Divider based on the pre-existing axes, i.e., ax object and return a new axis locator for the specified cell.
Create an axes at the given *position* with the same height (or width) of the main axes.
Create an axes at the given *position* with the same height (or width) of the main axes.
Create random data using numpy.
Create random data using numpy.
Use imshow() method to plot random data.
Use imshow() method to plot random data.
Set the title of the plot.
Set the title of the plot.
Instantiate the list of colormaps.
Instantiate the list of colormaps.
To animate the colorbar, use animate() method.
To animate the colorbar, use animate() method.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.axes_grid1 import make_axes_locatable

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

fig = plt.figure()

ax = fig.add_subplot(111)
div = make_axes_locatable(ax)
cax = div.append_axes('right', '5%', '5%')
data = np.random.rand(5, 5)
im = ax.imshow(data)
cb = fig.colorbar(im, cax=cax)
tx = ax.set_title('Frame 0')
cmap = ["copper", 'RdBu_r', 'Oranges', 'cividis', 'hot', 'plasma']

def animate(i):
   cax.cla()
   data = np.random.rand(5, 5)
   im = ax.imshow(data, cmap=cmap[i%len(cmap)])
   fig.colorbar(im, cax=cax)
   tx.set_text('Frame {0}'.format(i))
ani = animation.FuncAnimation(fig, animate, frames=10)

plt.show()
How to format a number with two decimals in JavaScript?

Use the toFixed() method in JavaScript to format a number with two decimals. The toFixed() method formats a number with a specific number of digits to the right of the decimal. It returns a string representation of the number that does not use exponential notation and has the exact number of digits after the decimal place.
You can try to run the following code to format a number with two decimals. Add the parameter of the toFixed() method to 2, for getting number with two decimals −
Live Demo
<html>
   <head>
      <title>JavaScript toFixed() Method</title>
   </head>
   <body>
      <script>
         var num1 = 4.6;
         var num2 = 177.1234;

         document.write("num1.toFixed() is : " + num1.toFixed(2));
         document.write("<br />");

         document.write("nu2m.toFixed() is : " + num2.toFixed(2));
         document.write("<br />");
      </script>
   </body>
</html>
num1.toFixed() is : 4.60
nu2m.toFixed() is : 177.12
MoviePy – Applying Speed effect on Video Clip

01 Aug, 2020
In this article we will see how we can apply speed effect on the video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. Speed up video or slow down also known as fast motion/slow-motion effects in video production, which makes the video clips play faster or slower than original speed.
In order to do this we will use fx method with the VideoFileClip object
Syntax : clip.fx( vfx.speedx, m)
Argument : It takes vfx object and multiplier as argument
Return : It returns VideoFileClip object
Below is the implementation
# Import everything needed to edit video clipsfrom moviepy.editor import *   # loading video dsa gfg intro videoclip = VideoFileClip("dsa_geek.webm")   # getting only first 5 secondsclip = clip.subclip(0, 5)   # applying speed effectfinal = clip.fx( vfx.speedx, 0.5)  # showing final clipfinal.ipython_display()
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Another example
# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video gfgclip = VideoFileClip("geeks.mp4")    # getting subclip from itclip = clip.subclip(0, 9)  # applying speed effectfinal = clip.fx( vfx.speedx, 2)  # showing final clipfinal.ipython_display()
Output :
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
                                                                                                                       
MoviePy - Done.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4


Python-MoviePy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Introduction To PYTHON
Python list remove()

21 Jun, 2022
Python List remove() is an inbuilt function in the Python programming language that removes a given object from the List. 
Syntax: 
list_name.remove(obj) 
Parameters:  
obj: object to be removed from the list 
Returns:  
The method does not return any value but removes the given object from the list.
Exception:
If the element doesn’t exist, it throws ValueError: list.remove(x): x not in list exception.
Note: 
It removes the first occurrence of the object from the list. 
Python3
# Python3 program to demonstrate the use of# remove() method # the first occurrence of 1 is removed from the listlist1 = [ 1, 2, 1, 1, 4, 5 ]list1.remove(1)print(list1) # removes 'a' from list2list2 = [ 'a', 'b', 'c', 'd' ]list2.remove('a')print(list2)
[2, 1, 1, 4, 5]
['b', 'c', 'd']

Python3
# Python3 program for the error in# remove() method  # removes 'e' from list2list2 = [ 'a', 'b', 'c', 'd' ] list2.remove('e')print(list2)
Output: 
Traceback (most recent call last):
  File "/home/e35b642d8d5c06d24e9b31c7e7b9a7fa.py", line 8, in 
    list2.remove('e') 
ValueError: list.remove(x): x not in list
Python3
# My Listlist2 = [ 'a', 'b', 'c', 'd', 'd', 'e', 'd' ] # removing 'd'list2.remove('d') print(list2)
['a', 'b', 'c', 'd', 'e', 'd']

Note: If a list contains duplicate elements, it removes the first occurrence of the object from the list. 
Python3
# Python3 program for practical application# of removing 1 until all 1 are removed from the list  list1 = [1, 2, 3, 4, 1, 1, 1, 4, 5] # looping till all 1's are removedwhile (list1.count(1)):    list1.remove(1)     print(list1)
[2, 3, 4, 4, 5]

Python3
# Python3 program for practical application# of removing 2 until all 2 are removed from the list mylist = [1, 2, 3, 2, 2] # looping till all 2's are removedwhile 2 in mylist:    mylist.remove(2) print(mylist)
[1, 3]

Complexity Class:  
Average case : O(N)
Amortised Worst case : O(N)
rajinkya26
sooda367
AmiyaRanjanRout
devendrasalunke
Python-Built-in-functions
python-list
python-list-functions
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to drop one or multiple columns in Pandas Dataframe
Copy Constructor vs Assignment Operator in C++

10 May, 2022
Copy constructor and Assignment operator are similar as they are both used to initialize one object using another object. But, there are some basic differences between them:
Syntax:
className(const className &obj) {
// body 
}
Syntax: 
className obj1, obj2;
obj2 = obj1;
Consider the following C++ program. 
CPP
// CPP Program to demonstrate the use of copy constructor// and assignment operator#include <iostream>#include <stdio.h>using namespace std; class Test {public:    Test() {}    Test(const Test& t)    {        cout << "Copy constructor called " << endl;    }     Test& operator=(const Test& t)    {        cout << "Assignment operator called " << endl;        return *this;    }}; // Driver codeint main(){    Test t1, t2;    t2 = t1;    Test t3 = t1;    getchar();    return 0;}
Assignment operator called 
Copy constructor called 
Explanation: Here, t2 = t1;  calls the assignment operator, same as t2.operator=(t1); and  Test t3 = t1;  calls the copy constructor, same as Test t3(t1);
Must Read: When is a Copy Constructor Called in C++?
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
anshikajain26
connorsfitzgerald
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Priority Queue in C++ Standard Template Library (STL)
Substring in C++
C++ Classes and Objects
Sorting a vector in C++
2D Vector In C++ With User Defined Size
C++ Data Types
Templates in C++ with Examples