Programming Articles - Page 169 of 2501

Length of longest subset consisting of A 0s and B 1s from an array of strings

Shubham Vora
Updated on 28-Jul-2023 12:52:55

210 Views

In this problem, we need to find the longest subset containing at most A 0s and B1s. All we need to do is find all possible subsets using the array elements and find the longest subset containing maximum A 0s and B1. In this tutorial, first, we will learn the recursive approach to solve the problem. After that, we will optimize the code using the dynamic programming approach. Problem statement − We have given an array containing N binary strings. Also, we have given A and B integers. We need to make the longest subset using the given binary strings ... Read More

Construct a K-length binary string from an array based on given conditions

Shubham Vora
Updated on 28-Jul-2023 12:50:54

218 Views

In this tutorial, we require to construct a binary string of length K such that it should contain ‘1’ at the ith index if a subset-sum equal to I is possible using array elements. We will learn two approaches to solving the problem. In the first approach, we will use a dynamic programming approach to check whether the subset sum equal to index ‘I’ is possible. In the second approach, we will use a bitset to find all possible sums using array elements. Problem statement − We have given an array containing N integers. Also, we have given integer M ... Read More

Minimum flips required to generate continuous substrings of 0’s and 1’s

Sakshi Koshta
Updated on 31-Jul-2023 13:26:52

1K+ Views

Continuous character sequences known as substrings of 0s and 1s can be created by selecting zero or more characters from the original string in any order without skipping any of them. Take for instance the string "0101." The sub strings that are followed up this text are: 0, " "1, " "01, " "10, " "010, " "101, " and "0101." The unfilled string is likewise a substring of all strings since it very well might be made by picking precisely 0 characters from the beginning string. As a result, in this instance "" is also a substring of "0101". ... Read More

Check if a string can be split into 3 substrings such that one of them is a substring of the other two

Shubham Vora
Updated on 28-Jul-2023 12:48:15

214 Views

In this problem, we need to split the given string in such a way that the third substring can be a substring of the first two substrings. Let’s think about the solution. The third string can be a substring of the first two string only if the first two string contains all characters of the third string. So, we need to find at least one character in the given string with a frequency of more than 3, and we can take the third substring of the single character. Problem statement − We have given a string str containing the N ... Read More

Mobile

Check if a graph constructed from an array based on given conditions consists of a cycle or not

Someswar Pal
Updated on 28-Jul-2023 11:34:05

248 Views

Introduction In graph theory, it is a very important task to figure out if a graph built from an array and meeting certain conditions has a cycle or not. A graph is an imaginary way to show how things are linked together. It is used in a lot of places, like computer networks and social networks. This article talks about the conditions for graph construction, the BFS and DFS algorithm, and a step by step guide how loops in a undirected graph is identified. Array Representation of a Graph An array-based method in graph theory stores vertices and edges in ... Read More

Check if a Binary String can be sorted in decreasing order by removing non-adjacent characters

Shubham Vora
Updated on 28-Jul-2023 12:46:14

242 Views

In this problem, we need to sort the given binary string in decreasing order by removing only non-adjacent elements. To solve the problem, we require to remove all zeros which are placed before ones in the binary string. If we find two consecutive ones after two consecutive zeros at any position in the string, it means we can’t sort the string in decreasing order. Otherwise, we can sort it out in each case. Problem statement − We have given binary string str with a length equal to N. We need to check whether we can sort the given string in ... Read More

Successor Graphs

Someswar Pal
Updated on 28-Jul-2023 11:32:13

1K+ Views

Introduction A Successor Graph is a model of a directed graph in which each node stores a list of the nodes that come after it. Successor graphs are better than an adjacency matrix or list because they speed up access to outgoing edges. This makes them perfect for algorithms that need quick access to successor vertices. This choice of design works well for graphs with a lot of points but not many edges Representation of Successor Graphs using Adjacency Matrix Successor graphs store only the direct successors of each vertex, reducing memory usage and speeding up edge insertion and deletion ... Read More

Print matrix elements using DFS traversal

Someswar Pal
Updated on 28-Jul-2023 11:26:51

1K+ Views

Introduction Depth-First Search (DFS) is a graph traversal method that looks at vertices and edges by starting at a certain node and going as far as possible down each branch before going back.It looks at the "depth" of the graph, starting with the node that is the deepest and then going back to look at other lines. Recursion or a stack can be used to make DFS work. It can be used to find paths, find cycles in graphs and vectors, and do exhaustive searches. Understanding the Matrix Structure In data analysis, a matrix is a two-dimensional array. Matrix data ... Read More

Maven Project with Junit – Checking for a Bank Account Number

Way2Class
Updated on 28-Jul-2023 11:05:49

238 Views

All the applications whether small or large are required to undergo a set of processes building, generating, compiling and running of the source code. These set of processes are manually performed by the programmers. However, with the launch of the Apache’s Maven Project, all these sets of processes can be automated and the manual work can be avoided. Therefore, the maven project is an open source tool that is used to build and deploy several projects at once for providing better project management. In this article, we will be discussing the Maven Project for checking a bank account number whether ... Read More

What is MetaSpace in Java?

Way2Class
Updated on 28-Jul-2023 10:57:26

2K+ Views

"MetaSpace" is not a phrase that is generally used or recognised as part of the Java Programming language’s standard library or syntax. As a result, "MetaSpace" is likely to relate to anything specific to a particular Java programme or project, rather than a general Java idea. It is impossible to offer a detailed description or explanation of "MetaSpace" in Java without further context or infformation about the individual application or project. However, it’s possible that "MetaSpace" refers to thhe physical world rather than the digital or virtual world. It may be used in this context to distinguish between online or ... Read More

Advertisements