Tag: Two):
How to Merge two HashSets in Java
In this article we will discuss how to merge two HashSets. HashSet provides a member function addAll() i.e. Advertisements public boolean addAll(Collection<? extends E> c) It provides a functionality to add a collection into to a HashSet. But this Collection should be of Same Type as of HashSet or of its Base Class. How addAll() works It …
Python : Join / Merge lists ( two or more)
In this article we will discuss different ways to Merge / Join two or more lists in python. Table of Contents Join / Merge two lists in python using + operator. Join / Merge two lists in python using list.extend(). Join / Merge two lists in python using unpacking. Join / Merge two lists in …
How to compare two vectors in C++
In this article, we will discuss different ways to compare two vectors in C++. Table Of Contents Comparing two vectors using operator == Comparing two vectors using STL Algorithm std::equal() Comparing two vectors with custom comparators Summary Best Courses to Learn Modern C++, like C++11, C++17 and C++20 Comparing two vectors using operator == std::vector …
How to Merge two or more Dictionaries in Python ?
In this article we will discuss different ways to merge two or more dictionaries. Also, handle scenarios where we need to keep the values of common keys instead of overwriting them. Merge two dictionaries using dict.update() In Python, the Dictionary class provides a function update() i.e. Advertisements dict.update([other]) It accepts an another dictionary or an …
Python: check if two lists are equal or not ( covers both Ordered & Unordered lists)
In this article we will discuss 8 different ways to check if two lists are equal or not. Suppose we have two lists and we want to check if both the lists are equal or not. There can be two meanings of 2 equality here, Advertisements Both lists must contain the same unique elements and …
Python: check if two lists are equal or not ( covers both Ordered & Unordered lists)Read More
Compare & get differences between two lists in Python
In this article we will discuss 10 different ways to compare two lists and get their differences i.e. elements which are present in one list but not in another. Suppose we have two lists, Advertisements first_list = [10, 11, 12, 13, 14, 16, 15] sec_list = [10, 11, 12, 18, 19, 16] Now there might …
Compare & get differences between two lists in PythonRead More
Pandas: Add two columns into a new column in Dataframe
In this article we will discuss different techniques to sum values of two columns in a dataframe and assign summed values as a new column. We will also cover the scenarios where columns contain NaN values. Suppose we have a Dataframe which contains employee name as an index and each column contains their monthly salaries, …
Pandas: Add two columns into a new column in DataframeRead More
How to print Two Dimensional (2D) Vector in C++ ?
In this article, we will discuss different ways to print the contents of a two dimensional vector in C++. Table of Contents Print two dimensional vector using range based for loops C++: Print 2D vector by overloading << operator & using indexing Print 2D Vector / Matrix in one line using lambda inside lambda In …
C++: How to initialize two dimensional Vector? – (Initializing 2D Vectors / Matrix)
In this article we will discuss different ways to initialize two dimensional in C++. Table of Contents C++: Initialize 2D vector with hardcoded values using initializer list C++: Initialize 2D vector with same value Initialize 2D vector with different values in each row C++: Create an empty 2D vector and the resize to fill values …
C++: How to initialize two dimensional Vector? – (Initializing 2D Vectors / Matrix)Read More
Python: Get difference between two dates in years
In this article, we will discuss how to get the difference between two dates in years in python. In python, the dateutil module provides a class relativedelta, which represents an interval of time. The relativedelta class has following attributes which tells about the duration, Year Month Day Hours Minutes Seconds Microseconds So, to calculate the …