Found 34494 Articles for Programming

Array obtained by repeatedly reversing array after every insertion from the given array

Divya Sahni
Updated on 25-Oct-2023 12:50:05

47 Views

Array insertion and reversal are one of the most common array manipulation techniques. Array manipulation aims to modify an array's contents to get a desired outcome. Problem Statement Given an input array A[]. The task is to insert the elements of the given array into an existing array where a reversal of the output array follows each insertion. Sample Example 1 − Input: A[] = {1, 2, 3, 4, 5} Output: R[] = {5, 3, 1, 2, 4} Explanation Initially, the output array R[] is empty. Insertion of 1 : R[] = {1} Insertion of 2 : ... Read More

Print the frequency of adjacent repeating characters in a given string

Vanshika Sood
Updated on 25-Oct-2023 12:05:37

93 Views

A string is a data structure consisting of a sequence of characters. The end of the string is marked by a special character, called a null character, which is usually represented by the ASCII code 0. Problem Statement Given a string s of a certain length, the task at hand is to print adjacent repeating characters along with the frequency of their repetition. For Example Input: s = “committee” Output: [[m, 2], [t, 2], [e, 2]] Explanation The character m occurs consecutively twice. Similarly the character t and e also occur twice consecutively. Therefore we return the vector ... Read More

Minimize removals to remove another string as a subsequence of a given string

Vanshika Sood
Updated on 25-Oct-2023 12:01:38

109 Views

A subsequence refers to a sequence that can be obtained from another sequence by removing zero or more elements, without altering the order of the remaining elements. In simpler terms, a subsequence is derived by selecting elements from the original sequence, while preserving their relative order. For example, consider the sequence [1, 2, 3, 4]. Some possible subsequences of this sequence are: [1, 2], [1, 3, 4], [2, 4], [1, 2, 3, 4], [3], and [4]. Problem Statement The objective is to determine the minimum number of character removals from string s1 in order to eliminate any occurrence of ... Read More

Check if given string is prefix subarray of the given array

Vanshika Sood
Updated on 25-Oct-2023 11:59:25

58 Views

A subarray of an array is a contiguous part of the array in which we take a group of consecutive elements while also maintaining the relative ordering of elements as present in the original array. Example − Some valid subarrays are − etc. A prefix subarray is a special type of subarray that begins with the first element of the array and ends at some ith index where 0

Check if every row in given Matrix contains all the integers from 1 to N

Vanshika Sood
Updated on 25-Oct-2023 11:52:35

61 Views

A matrix is a two-dimensional data structure made up of rows and columns set out like a grid of squares. Grids, multidimensional arrays, and tabular data are frequently represented using it. Problem Statement We are given a matrix of dimensions and the task is to check whether each row of the matrix consists of every number from 1 to n. The order of the numbers in the row do not matter. Return true if this statement holds true else return false. For Example Input: mtx = [[1, 2, 3], [3, 2, 1], [2, 1, 3]] Output: True ... Read More

Find the last remaining Character in the Binary String according to the given conditions

Disha Gupta
Updated on 23-Oct-2023 15:43:53

35 Views

A binary string is a string that only has two characters, usually the numbers 0 and 1, and it represents a series of binary digits. Problem Statement Now, in this problem, we are given a binary string comprising zeros and ones. We have two conditions to keep in mind while solving the problem. First, one digit can delete another digit that is a ‘1’ can delete a ‘0’ and vice versa. Secondly, if at any moment the entire string consists of only 0’s and 1’s then the corresponding digit is printed. Here, a binary string will be the input given ... Read More

Difference between casefold() and lower() in Python

Pranavnath
Updated on 23-Oct-2023 15:25:50

274 Views

Introduction Python is a versatile programming language, provides several built-in methods for manipulating strings. Two commonly used methods are `casefold()` and `lower()`. While they may appear similar at first, there are some differences that make them unique and suited for specific use cases. Both methods help in case-insensitive string comparisons, it's crucial to highlight that their outcomes may vary depending on the local settings of our Python environment. Therefore, it is recommended to be aware of these settings and choose the method accordingly to ensure accurate results. Python – Casefold() and Lower() Casefold() The casefold() method is used to perform ... Read More

math.Float64bits() Function in Golang With Examples

Pranavnath
Updated on 23-Oct-2023 15:25:01

112 Views

Introduction In the world of programming, effectiveness, and accuracy are vital. One dialect that grasps these standards is Go, too known as Golang. One significant angle of programming is working with numbers, and when it comes to floating-point numbers, precision things. This can be where the math.Float64bits() function in Golang sparkles. In this article, we are going to delve into the complexities of math.Float64bits() work, look at its noteworthiness and challenges in different applications, and eventually get its part within the broader setting of Golang programming. Overview of Float64 in Golang The float64 type in Golang uses the IEEE 754 standard representation to ... Read More

io.Pipe() Function in Golang with Examples

Pranavnath
Updated on 23-Oct-2023 15:20:36

170 Views

Introduction The world of programming embraces effectiveness and adaptability, and Golang, or Go, encapsulates these standards. Among its flexible highlights, the io.Pipe() function stands out. This Golang work, found within the io bundle, encourages inter-goroutine communication by making in-memory channels. These channels permit consistent information exchange, streamlining concurrent preparation. This article digs into the profundities of io.Pipe(), investigating its mechanics, focal points, downsides, and real-world significance. Understanding this work not as it improved your Golang proficiency but also enables you to form more productive and robust concurrent programs. Overview of io.Pipe() Function? The io.Pipe() function returns a connected pair of ... Read More

Matplotlib.figure.Figure.draw() in Python

Pranavnath
Updated on 23-Oct-2023 15:26:36

151 Views

Introduction The Matplotlib.figure.Figure.draw() method stands as a foundation inside the Matplotlib library, a crucial instrument for visualizing information utilizing Python. At the heart of the Matplotlib plotting system, this strategy plays an urgent part in changing theoretical information representations into tangible visualizations. By digging into the perplexing workings of Matplotlib.figure.Figure.draw(), one can reveal its centrality in rendering plots, empowering energetic intuitive, and encouraging the creation of outwardly engaging design. This article sets out on a travel to unwind the mechanics and suggestions of this strategy, investigating its preferences, impediments, applications present within the domain of information visualization. What is Matplotlib.figure.Figure.draw()? ... Read More

Advertisements