Decrease and Conquer

Thanweera Nourin A V
Updated on 23-Aug-2023 21:37:34

3K+ Views

Imagine yourself in a situation where you are having trouble coming up with a solution to your initial issue. What if I told you that a small part of the problem is simpler to solve and that you can use this answer to find the answer to the larger one? Interesting? The decrease and conquer strategy achieves just this. A problem-solving strategy known as "Decrease and Conquer" involves slicing the size of the input at every stage of the solution procedure. Identical to divide-and-conquer as it breaks the problem down into smaller sub-problems, decrease-and-conquer reduces the size of the ... Read More

Decimal Representation of Binary String Divisible by 20

Thanweera Nourin A V
Updated on 23-Aug-2023 21:36:19

123 Views

In this article, we take the challenge to determine whether or not the given binary number's decimal form can be divided by 20. The base-2 numeral system, often known as the binary numeral system, is a way of expressing numbers in mathematics that employs just two symbols, commonly "0" (zero) and "1." (one). For instance, the decimal number 4 is represented as 100 in binary form. The binary form of the decimal number 6 is 110. The binary representation is 11100 for the decimal number 28. Now think how the decimal number 1, 23, 45, 687 can be represented as ... Read More

Find Words Greater Than Given Length K Using StringStream

Avinash Gupta
Updated on 23-Aug-2023 21:30:42

247 Views

This is the problem based on stringstream class present in C++ “sstream” header file. Here, we have to find those strings whose lengths are greater than “k”. This task will be performed by using stringstream class. The concept is to partition the string and then iterate through the defined words. The value of length k has to be specified to obtain the words which are larger than k whereas the length of the words which are smaller than k will not be displayed in the output. In this article, we will understand how to find words which are greater than ... Read More

Length of Longest Common Subsequence Containing Vowels

Avinash Gupta
Updated on 23-Aug-2023 21:28:51

314 Views

In this problem, our task is to find the length of the longest possible subsequence present in two strings such that every letter of the subsequence must be a vowel. With the help of the recursive algorithm and iterative algorithm, the given problem statement can be solved. In English Alphabet, there exist five vowels named 'A', 'E', 'I', 'O', 'U'. Subsequence Vs. Substring: In Subsequence, we may take characters in a non-continuous way, but in Substring, we can take only continuous characters. Ex: In String “TutorialsPoint”: “tri” is a subsequence but not a substring. While “tor” is both subsequence ... Read More

Delete Row from DataFrame in Python Pandas

AmitDiwan
Updated on 23-Aug-2023 21:13:18

63K+ Views

To delete a row from a DataFrame, use the drop() method and set the index label as the parameter.At first, let us create a DataFrame. We have index label as w, x, y, and z:dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35], [40, 45]], index=['w', 'x', 'y', 'z'], columns=['a', 'b'])Now, let us use the index label and delete a row. Here, we will delete a row with index label 'w'.dataFrame = dataFrame.drop('w') ExampleFollowing is the codeimport pandas as pd # Create DataFrame dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35], [40, 45]], index=['w', 'x', 'y', 'z'], columns=['a', 'b']) ... Read More

Python Object Inspector

Gireesha Devara
Updated on 23-Aug-2023 19:09:55

458 Views

In python there is no built−in or normal function that acts as an object inspector. But we can use functions like type(), help(), dir(), vars() or modules like inspect are used to find the attributes, properties and methods of any object. Also we have other functions like id(), getattr(), hasattr(), globals(), locals(), callable() are useful in looking inside an object to know its attributes and methods. Here we will inspect the objects using some built−in functions. Before that we will create a simple python class and its objects, to refer throughout this article. Following is the syntax to defing ... Read More

Break a For Loop in Python

Gireesha Devara
Updated on 23-Aug-2023 19:08:22

2K+ Views

In Python normally for loops are constructed to iterate over a block for each item in a range. If a premature termination of loop is sought before all iterations are completed, then we can use break keyword. It is invariably used in a conditional statement inside the body of a loop. Using the break statement Let’s take a few examples to see how the break statement works on for loops. Example In this example the for loop is defined to iterate upto 20 loops, but the break statement terminates the for loop at 10th iteration i.e., x=10. If we ... Read More

Prevent Loops from Going into Infinite Mode in Python

Gireesha Devara
Updated on 23-Aug-2023 19:02:26

3K+ Views

In python the while loop needs to be controlled by making some provision inside the body of the loop to drive the condition mentioned in the beginning to false. This is usually done by keeping count of iterations. If the while loop condition never evaluates to False, then we will have an infinite loop, which is a loop that never stops automatically, in this case we need to interrupt externally. count=0 while condition: stmt1 stmt2 . . count=count+1 Example Let’s take an example and ... Read More

Convert Float to Integer in Python

Gireesha Devara
Updated on 23-Aug-2023 18:42:17

2K+ Views

In python there are two number data types: integers and floats. In general integers do not have any decimal points and base value is 10 (i.e., Decimal). Whereas floats have decimal points. Python provides some built−in methods to convert floats to integers. In this article we will discuss some of them. Using the int() function The int() function converts the floating point numbers to integers, by removing the decimals and remains only the integer part. Also the int() function does not round the float values like 49.8 up to 50. Example In the example the data after the decimal ... Read More

Convert Integer to Character in Python

Gireesha Devara
Updated on 23-Aug-2023 18:36:02

37K+ Views

To convert an integer to a character in Python, we can use the chr() method. The chr() is a Python built−in method that returns a character from an integer. The method takes an integer value and returns a unicode character corresponding to that integer. Syntax char(number) Parameter The method takes a single integer between the range of 0 to 1, 114, 111. Return Value A unicode character of the corresponding integer argument. And it will raies a ValueError if we pass an out of range value (i, e. range(0x110000)). Also it will raise TypeError − for a non−integer argument. ... Read More

Advertisements