Found 34494 Articles for Programming

Connecting PostgreSQL with SQLAlchemy in Python

Utkarsha Nathani
Updated on 13-Sep-2023 10:54:27

3K+ Views

Python provides variety of libraries one of them is SQLAlchemy, it provides an Object Relational Mapping (ORM) system for working with databases, including PostgreSQL. It is used for the purpose of storing and managing huge amount of structured data by the developers. By connecting both of them we can create a more productive and efficient database. In this article, we will learn how to connect PostgreSQL with SQLAlchemy in Python. What is SQLAlchemy? It is a powerful library that helps in simplifying the process of working with the databases, and is widely used in web development and data analysis. ... Read More

Connect to MySQL using PyMySQL in Python

Utkarsha Nathani
Updated on 13-Sep-2023 10:59:56

4K+ Views

What is PyMySQL? It is a python library which is used for connecting MySQL database. It is completely written in Python and uses python for communicating with MySQL server. Compatible with Python 2.7 and python 3.x, and provides a simple and instinctive interface for connecting to the MySQL database, executing SQL queries and for retrieving results. Why PyMySQL? It does not require any additional software, it is easy to use, provides security that is it supports SSL connections for secure communication, hence it is a popular choice for building Python applications that require database connectivity. What is MySQL MySQL ... Read More

Minimum Removals are Required such that a given String Consists only of a Pair of Alternating Characters

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 18:30:53

120 Views

Minimum removals required such that a given string consists only of a pair of alternating characters is a common problem in computer science and is encountered frequently in applications involving string manipulation. In this tutorial, we will solve this problem using the C++ programming language. We will begin by explaining the problem statement in detail and discussing its importance in various real-world applications. Then, we will provide a step-by-step algorithm to solve this problem and demonstrate its implementation in C++. Finally, we will conclude with some insights into the time and space complexity of our solution ... Read More

Minimum Number of Replacements done of the Substring “01” with “110” to Remove it Completely

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 18:26:57

121 Views

The minimum number of replacements done of the substring “01” with “110” to remove it completely is a common problem in string manipulation and optimization. In this tutorial, we delve into this problem and present an efficient solution using C++. The problem entails finding the minimum number of replacements required to transform a binary string by replacing all occurrences of the substring "01" with "110" while ensuring that the resulting string does not contain the substring "10". We provide a detailed explanation of the problem statement, present an algorithmic approach to solve it, and offer a ... Read More

Minimum distance between Duplicates in a String

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 18:22:57

138 Views

Finding the minimum distance between duplicates in a string is a frequently encountered problem in computer science. It involves finding the smallest distance between any two identical characters in a given string. For example, in the string "minimum distance, " the minimum distance between the two 'i's is two, as they occur at positions 1 and 3, respectively. This problem can be solved using different programming languages, including C++. In this tutorial, we will learn a C++ algorithm with implementation to efficiently solve this problem. So let's get into this and learn something new and exciting! Problem ... Read More

The Maximum Score Possible by Removing Substrings made up of Single Distinct Character

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 18:20:59

156 Views

The maximum score possible by removing substrings made up of a single distinct character is a well-known problem in the field of computer science and algorithm design. The problem statement involves finding the optimal solution to remove all the contiguous substrings from a binary string that contains only one type of character and score points for every removed substring of length K, where K can vary for each substring. This problem has various real-life applications, including text analysis and compression. In this tutorial, we will provide a solution to this problem using C++, and explain the logic behind ... Read More

Maximize Time by Replacing ‘_’ in a given 24-Hour Format Time

Aishwarya Mani Tripathi
Updated on 23-Oct-2023 15:07:43

103 Views

Maximizing time by replacing ‘_’ in a given 24-hour format time is a problem that involves calculating the maximum possible time by replacing the missing digits in a given time in a 24-hour format. The task is to find the maximum time possible by replacing the characters ‘’ with any digit. In this tutorial, we will discuss how to solve this problem using the C++ programming language. We will provide a step-by-step explanation of the algorithm used to calculate the maximum possible time, along with the C++ code to implement the algorithm. Additionally, we will include test examples ... Read More

Lexicographically Kth-smallest string having ‘a’ X times and ‘b’ Y times

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 18:08:33

93 Views

Lexicographically Kth-smallest string having ‘a’ X times and ‘b’ Y times is a problem where we need to find the Kth smallest string that contains X number of ‘a’s and Y number of ‘b’s. The strings are arranged lexicographically which means that the smallest string comes first when we sort all the possible strings. In this tutorial, we will discuss how to solve this problem using C++. We will start by understanding the problem statement in detail, followed by the algorithmic approach. We will then move on to implementing the solution in C++ using dynamic programming. The code ... Read More

Flip the String by Either Swapping given Characters or Rotating it Horizontally for Q Queries

Aishwarya Mani Tripathi
Updated on 20-Oct-2023 15:09:31

69 Views

Flip the String by either swapping given characters or rotating it horizontally for Q queries is a fascinating problem that involves manipulating a string based on a series of queries. In this tutorial, we delve into this problem and provide a solution using C++. The problem statement revolves around a string of characters and a set of queries, each containing instructions to swap specific characters or perform a horizontal rotation. Our objective is to determine the final configuration of the string after applying all the queries. Through this tutorial, we will explore the intricacies of the ... Read More

Flip all 0s in given Binary Strings K times with different Neighbours

Aishwarya Mani Tripathi
Updated on 20-Oct-2023 15:04:36

108 Views

The task of flipping 0s in a binary string while considering their adjacent characters has practical applications in various domains. In this tutorial, we delve into the problem of modifying a given binary string by repeatedly flipping the 0s that have different adjacent characters. Specifically, we aim to solve this problem within the context of C++ programming. The solution involves iteratively scanning the string and applying the necessary flips based on the provided logic. By leveraging the string manipulation capabilities, we can efficiently transform the binary string by flipping 0s K times, ensuring that each flip adheres to the ... Read More

Advertisements