Programming Articles - Page 327 of 3363

Find Binary string by converting all 01 or 10 to 11 after M iterations

Prabhdeep Singh
Updated on 16-May-2023 13:38:01

273 Views

A binary string is a string that consists of only two different types of characters and that is ‘0’ and ‘1’. We will be given a binary string and the number m. We have to apply the operation to convert all the consecutive occurrences of the 0 and 1 that are ‘01’ and ‘10’ to ‘11’. One more condition is there that there must be only one neighbor of ‘0’ can be ‘1’. We can traverse over the string only m times where m will be given. Let’s understand with the following example Input 1: Given binary string: ‘01000101’ Given ... Read More

Python Program to convert an array into a string and join elements with a specified character

Gireesha Devara
Updated on 29-May-2023 14:20:57

368 Views

An array is a data structure consisting of a collection of elements of the same data type, and each element is identified by an index. [2, 4, 0, 5, 8] Arrays in Python Python does not have its own data structure to represent an array. Instead, we can use the list data structure to represent an array. Here, we will use list an array − [10, 4, 11, 76, 99] In the article, we will write a python programs to convert an array to a string and join elements with a specified character. ... Read More

Fibbinary Numbers (No consecutive 1s in binary) – O(1) Approach

Prabhdeep Singh
Updated on 16-May-2023 13:35:03

398 Views

Fibbinary Numbers are numbers that have no consecutive 1s in their binary representation. However, they can have consecutive zeros in their binary representation. Binary representation is the representation in which the numbers are shown with base 2 and only two digits that are 1 and 0 only. Here, we will be given a number and have to find whether the given number is the fibbinary number or not. Input 1: Given number: 10 Output: Yes Explanation − The binary representation of the given number 10 is 1010 which shows that, there is no consecutive one in the binary form. ... Read More

Next greater number on the basis of the precedence of digits

Prabhdeep Singh
Updated on 16-May-2023 13:33:02

179 Views

In the normal number system, 0 is the smallest digit while 9 is the largest digit. In this problem, we will be given a list of the length 10, and starting from index 0 to index 9 it represents a digit, which indicates the priority of that digit and the list will be in increasing order means the digit present at the last index is the with highest priority. We will be given a number also and we have to find the next number which is the just greater than the current number. Input 1: Given number = “123” ... Read More

Check if the given String can be split only into subsequences ABC

Prabhdeep Singh
Updated on 16-May-2023 13:28:41

300 Views

A subsequence of a string means part of a string in which characters can be taken from anywhere of the string (zero or more elements) without changing the order of the characters and forming a new string. In this problem, we have given a string of length N where every character of the string belongs to either ‘A’, ‘B’, or ‘C’ character. Our task is to find that the string can be split only into subsequences “ABC” or Not. If the string is split only into subsequences “ABC” then return “yes” otherwise return “no”. Input 1: str = “AABCBC” ... Read More

Check if the Decimal representation of the given Binary String is divisible by K or not

Prabhdeep Singh
Updated on 16-May-2023 12:36:08

645 Views

A binary string is a string that consists of only two different types of characters and that is ‘0’ and ‘1’, hare base is 2. And a decimal representation means each digit is lie between ‘0’ to ‘9’, here the base is 10. Here we have given a string of binary numbers and an integer k. we have to check if the decimal representation of the given binary string is divisible by k or not. If it is divisible then we have to return ‘yes’ otherwise return ‘no’. In the conversion of binary to decimal, we convert a base 2 ... Read More

Maximize the sum of selected numbers from an array to make it empty

Prabhdeep Singh
Updated on 16-May-2023 12:31:26

222 Views

We will be given an array and have to choose an element from it and add that element to the sum. After adding that element to the sum, we have to remove three elements from the array if they exist current number, current number -1, and current number + 1. By this method we will make the array empty and will get a sum. At the end, we have to make the sum maximum. Input: [ 1, 2, 3] Output: 4 Explanation At first, we can have three moves, delete 1, 2, or 3. Let ... Read More

How to Upload Image into Database and Display it using PHP

Tarun Singh
Updated on 14-Jul-2023 15:57:52

16K+ Views

In modern web applications, it is common to store images in databases for various reasons, such as security, easy management, and scalability. PHP, being a popular server-side scripting language, provides an easy way to upload images to databases and display them on the web pages. In this article, we will learn How to Upload Image into Database and Display it using PHP. PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open-source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. In the below article, we have demonstrated the examples with the ... Read More

Difference between Control Structure and Control Statement

Pranavnath
Updated on 17-May-2023 12:34:01

2K+ Views

Control structures and control statements are essential concepts in programming. A control structure could be a piece of code that controls the stream of execution of a program based on certain conditions. On the other hand, a control explanation could be a statement that performs a particular activity based on certain conditions. In this article, we'll investigate the difference between control structures and control explanations, their utilization, and how they contribute to the general usefulness of a program. We'll too talk about a few illustrations of commonly utilized control structures and articulations of completely different programming dialects. Control Structure A ... Read More

Program to print Hut Star pattern

Shriansh Kumar
Updated on 16-May-2023 11:21:11

831 Views

Solving interesting pattern problems enhances the understanding of loops. They are essential because they help in building a strong foundation of a particular programming language. There are various kinds of patterns including number-based, star-based and alphabetical patterns as well. This article will guide you to solve a hut star pattern using nested for loop in Java. Java Program to print Hut Star Pattern Since we are going to solve the problem using nested for loop therefore, it is necessary to discuss its syntax. Syntax for ( initial expression; conditional expression; increment/decrement expression ){ for ( ... Read More

Advertisements