Found 33676 Articles for Programming

Encoding a Sentence into Pig Latin

Shubham Vora
Updated on 25-Aug-2023 16:38:23

330 Views

In this problem, we will convert the sentence into Pig Latin. We can append the first character of each word at the last and append ‘ay’ after that. We will see three approaches to convert the given sentence into the Pig Latine. The logic is we can append the first character at the end and remove it from the string. After that, we can append ‘ay’ to the word. Problem statement – We have given a string alpha containing multiple words. We need to encode the string into Pig Latin. Note – The Pig Latine is a word encryption ... Read More

Why Logistic Regression in Classification in Machine Learning?

Mithilesh Pradhan
Updated on 27-Aug-2023 13:13:53

252 Views

Introduction Logistic Regression is a classification algorithm commonly used our machine learning for binary classification. Although the term "Regression" is in its name it is in fact a classification algorithm. It uses log odds with log loss or cross−entropy loss as the cost function. In this article let us see why Logistic Regression is a classification algorithm in nature. Logistic Regression as a Classification Algorithm A Linear Regression algorithm can be given represented by a linear equation such that a univariate regression model with $\mathrm{\alpha_{0}}$ intercept and $\mathrm{\alpha_{1}}$ can be written as $$\mathrm{y=\alpha_{0}+\alpha_{1}x}$$ The line of best fit is ... Read More

Check if Words in given Sentence Occur based on the given Pattern

Shubham Vora
Updated on 25-Aug-2023 16:33:06

207 Views

In this problem, we need to check whether the string follows the given pattern. We can solve the problem by mapping each character to the word. If any character of the pattern maps more than one word, we can say that the string is not following the pattern. Problem statement – We have given a ‘pat’ string containing N characters and an ‘alpha’ string containing N words. The given task is to check whether the ‘alpha’ string follows the pattern of the ‘pat’ string. Note – We can say that the ‘alpha’ string follows the pattern when the word matches ... Read More

Shortest String formed by Concatenating String A x Times and B y Times such that n(A)\x = n(B)*y

Shubham Vora
Updated on 25-Aug-2023 16:09:10

151 Views

In this problem, we need to find the shortest string, which is a multiple of string A and string B. The problem is very similar to finding the LCM (Least common multiplier) of two numbers. We can find the LCM of both strings’ lengths and make both strings’ lengths equal to LCM by concatenating to itself. After that, we can compare the string to check if it is possible to get the shortest string which multiple of A and B. Problem statement – We have given string A and string B of different lengths. We need to find the shortest ... Read More

Python3 Program to Find Maximum number of 0s placed consecutively at the start and end in any rotation of a Binary String

Shubham Vora
Updated on 25-Aug-2023 16:04:27

184 Views

In this problem, we will write the Python code to count the maximum sum of consecutive zeros at the start and end of the string. The problem solution can be divided into two parts. The first part is finding all rotations of the string. The second part is finding the starting and ending consecutive zeros in all rotations of the binary string. Another way to solve the problem is that counting the maximum consecutive zeros can answer the problem. Problem statement – We need to find the total number of maximum consecutive zeros at the start and end ... Read More

Python3 Program for Queries for Rotation and Kth Character of the given String in Constant Time

Shubham Vora
Updated on 25-Aug-2023 15:57:46

121 Views

In this problem, we need to perform the queries according to the given rules and print the characters from the updated string. We will solve the problem using two different approach. In the first approach, we will use the string rotation concept, and in the second approach, we will use the index customization approach. Problem statement – The task given to us is that perform given queries on the string. We have given the array of queries, and each query contains two integers. Follow the below statements to perform the given queries on the string. (1, l) – ... Read More

Program to convert given Binary to its equivalent ASCII character string

Shubham Vora
Updated on 25-Aug-2023 15:53:18

569 Views

In this problem, we need to convert the binary string to the character string. We can convert the binary string to an ASCII number string first, and then we can convert the character string. Problem statement – We have given a binary string bin_str whose size is multiple of 8. We need to convert the binary string to the character string. Sample examples Input bin_str = "0110110001101010" Output 'lj' Explanation – The ‘01101100’ is equivalent to 108 in the decimal, which is equivalent to the ASCII value of the ‘l’. The ‘01101010’ equals 106, and ... Read More

Minimum Number of Insertions in given String to Remove Adjacent Duplicates

Shubham Vora
Updated on 25-Aug-2023 15:49:58

119 Views

In this problem, we will count the minimum number of characters we need to insert to remove all adjacent duplicate characters. To solve the problem, we need to count the total number of adjacent duplicate character pairs. Problem statement – We have given a string named str containing N alphabetical characters. We need to find the total number of different characters we require to add to the string such that the resultant string shouldn’t contain any adjacent duplicated characters. Sample examples Input str = "ccddrt" Output 2 Explanation – We need to insert one character ... Read More

Use Cases of Generative Adversarial Networks

Mithilesh Pradhan
Updated on 27-Aug-2023 13:10:34

187 Views

Introduction In recent years Generative Adversarial Networks have gained a lot of traction and used in numerous use cases. GANs are deep neural network architectures used to generate realistic synthetic data from existing data sets. GANs have two sets of neural networks − the first one generates new images and the second one discriminates between real and generated images. The discriminants give feedback to the generator about the image whether it is real or fake so that the generator can produce better images that look exactly like the real ones. This process is continued till the discriminator fails to differentiate ... Read More

Minimum Jumps from Either End to Reach Largest and Smallest Character in given String

Shubham Vora
Updated on 25-Aug-2023 15:43:26

154 Views

In this problem, we require to find the minimum jumps required to make to reach the largest and smallest character in the given string. We can move to the next or previous character in one jump. We can solve the problem by finding the position of the lexicographically largest and smallest character in the given string. After that, we can find the minimum jumps required to the found indexes from the left and right sides. Problem statement – We have a string str of length N containing the alphabetical characters in the uppercase. We need to find the minimum number ... Read More

Advertisements