Programming Articles

Page 1815 of 2547

Java Equivalent of C++\'s lower_bound() Method

Rushi Javiya
Rushi Javiya
Updated on 24-Jul-2023 1K+ Views

In this problem, we will learn to implement the equivalent algorithm of C++'s lower_bound() method in Java to find the lower bound index of a given element in the sorted array. Lower bound − The lower bound is the index in the sorted array, such that the index contains the minimum element greater or equal to the targeted element. We can use the searching algorithms to find the lower bound of any element in the sorted array without using built-in methods. Here, we will use the linear search, iterative, and recursive binary search to get the lower bound of any ...

Read More

Golang program to calculate the symmetric difference between two slices

Akhil Sharma
Akhil Sharma
Updated on 24-Jul-2023 644 Views

Slice is similar to an array, the only difference is that an array is a fixed sequence of elements whereas slice the array elements are dynamic. This makes the slice more efficient and faster in various applications. In the slice, the elements are passed by reference instead of values. In this article, we are going to learn about different techniques to calculate the symmetric difference between two slice using Golang programming. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and ...

Read More

Characteristics of .NET Framework

Siva Sai
Siva Sai
Updated on 24-Jul-2023 4K+ Views

In the realm of software development, Microsoft's .NET Framework has revolutionized the industry with its comprehensive and consistent programming model for creating applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes. This article seeks to highlight the key characteristics of the .NET Framework that make it a vital tool for developers worldwide. What is .NET Framework? The .NET Framework, a software framework developed by Microsoft, is a platform for building various types of applications. From Windows-based applications to web-based applications and services, the .NET Framework provides a large ...

Read More

Maximum distance between two points in coordinate plane using Rotating Caliper’s Method

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 24-Jul-2023 338 Views

In C++ we have a predefined function sqrt that returns the square root of any number. The Rotating Caliper’s Method is the technique used to solve the algorithmic or computational geometry. Visual Representation of Rotating Caliper’s MethodThe hand rotation shows the real example of a rotating caliper graph, whenever the hand rotates the perpendicular direction is shown. We can also understand this concept by using a polygon shape. In this article, we are going to find the maximum distance of two coordinate points using Rotating Caliper’s Method. Syntax The following syntax used in the program − vector name ...

Read More

Find the Number of \'X\' Total Shapes

Shubham Vora
Shubham Vora
Updated on 22-Jul-2023 264 Views

In this problem, we need to find the total number of ‘X’ shapes in the given matrix. We can construct the single ‘X’ shape using 1 or more adjacent ‘X’ elements. We can use the DFS (depth−first search) technique to solve the problem. For each ‘X’ element, we can find all adjacent elements using DFS and count it as a single ‘X’ shape. If we find a new ‘X’, we find its adjacent again. Here, we will use the iterative and recursive DFS to find the total number of ‘X” shapes. Problem statement − We have given a matrix[] of ...

Read More

Sum of Minimum and Maximum Elements of all Subarrays of Size K.

Shubham Vora
Shubham Vora
Updated on 22-Jul-2023 873 Views

In this problem, we need to take the maximum and minimum elements of all sub−array of length K and add them to get the answer. The first solution approach is that traverse through all sub−arrays of size K, find the minimum and maximum element of each sub−array, and add them. The optimized approach to solve the problem is using the deque data structure. We will store the index of the minimum and maximum elements of the subarray in the deque. Problem statement − We have given an array nums[] containing N positive or negative integer values. We have also ...

Read More

Reduce the Array to Atmost one Element by the Given Operations

Shubham Vora
Shubham Vora
Updated on 22-Jul-2023 219 Views

In this problem, we will reduce the array size to 1 or 0 by performing the given operations in each turn. We can sort the array in each turn to get the maximum elements in each iteration. Also, we can use the head data structure to improve the performance of the code. Problem statement − We have given a nums[] array. We need to decrease the array by performing the below operations. Choose two maximum elements of the array. If both elements are the same, remove both elements from the array. If both elements are not the same, remove ...

Read More

Rearrange and Update Array Elements as Specified by the given Queries

Shubham Vora
Shubham Vora
Updated on 22-Jul-2023 358 Views

In this problem, we will perform the given queries on the array elements. The queries contain the circular left rotation, right rotation, and updation of the array element. The logical part of solving the problem is array rotation. The naïve approach to rotating the array in the left direction is to replace each element with the next element and the last element with the first element. We can use the deque data structure to rotate the array efficiently. Problem statement − We have given an arr[] array containing the integer values. Also, we have given a queries[] array containing ...

Read More

Print all Prime Levels of a Binary Tree

Shubham Vora
Shubham Vora
Updated on 22-Jul-2023 203 Views

In this problem, we will print all prime levels of the given binary tree. We will use the level order traversal technique to traverse each binary tree level and check whether all nodes contain the prime integer for the particular level. Problem statement − We have given a binary tree and need to print all prime levels of the binary tree. It is given that if all nodes of any binary tree contain a prime integer, we can say a particular level is a prime level. Sample examples Input  ...

Read More

Print all Palindromic Levels of a Binary Tree

Shubham Vora
Shubham Vora
Updated on 22-Jul-2023 267 Views

In this problem, we will print each palindromic level of the given binary tree. We can use the breadth−first search algorithm to traverse each level of the given binary tree and check whether a particular level of the binary tree is palindromic. If yes, we print the level in the output. Problem statement − We have given a binary tree, and we need to print all palindromic levels of the binary tree. If any particular level of the binary tree contains the same numbers from left to right and right to left, we can say that the current level is ...

Read More
Showing 18141–18150 of 25,466 articles
Advertisements