Found 1239 Articles for Data Structure

Java Program for Left Rotation and Right Rotation of a String

Prabhdeep Singh
Updated on 11-Jul-2023 08:55:14
Rotation means we have to shift each character either in a forward direction or backward direction. Forward direction means right rotation (Or anticlockwise) and backward direction means left rotation (Or clockwise). In this problem, we have given a string of characters of size n and integer d. Here d is less than n. Our task is to print the left rotated string or right rotated string by d integer. Only the permutation of the current string changes, not the length or frequency of the characters in the given string. Input 1 str = “apple”, d = 2 Output 1 Left ... Read More

Sort a string without altering the position of vowels

Prabhdeep Singh
Updated on 11-Jul-2023 09:02:29
Sorting a string means we have to arrange a given string either in an ascending or descending order or any given order. In this problem given a string 'str' of size n. Our aim is to sort the given string without altering means without changing the position of vowels present in the string. Let's see examples with explanations below to understand the problem in a better way. Sample Examples Input 1 str = “abdecokfee” Output 1 abcedofkee Explanation Constant present in the string = bdckf Sort the constant string = bcdfk Merge the given string with the sorted instant string ... Read More

Maximum Number of 0s Placed Consecutively at the Start and End in any Rotation of a Binary String

Prabhdeep Singh
Updated on 11-Jul-2023 09:00:04
Binary string means the string contains only two types of char either 1 or 0. It is known as base 2. In this problem, we have given a binary string str and also the size of the string 'n'. Our task is to find the maximum number of zeros places consecutively at the start and end of any rotation of a binary string. Let's see examples with explanations below to understand the problem in a better way. Sample Example Input 1 str = “101001, n = 6 Output 1 2 Explanation The string can be rotated in any of the ... Read More

C++ Program for Left Rotation and Right Rotation of a String

Prabhdeep Singh
Updated on 11-Jul-2023 08:56:40
Rotation means we have to shift each character forward or backward direction. In the case of forward, the last character is forwarded to the index 0 also known as right rotation. In the case of backward first character at index 0 is backward to the last index also known as left rotation. In this problem, we have given a string of characters and integer d. Our task is to print the left rotated string or right rotated string by d integer. Only the permutation of the current string changes, not the length or frequency of the characters in the ... Read More

How to Deploy Redis Cluster on Kubernetes?

Satish Kumar
Updated on 10-Jul-2023 18:41:29
Introduction Redis is a widely used open-source, in-memory data structure store, used as a database, cache, and message broker. It is designed to handle a large set of data structures with high performance and flexibility. Redis Cluster is a distributed implementation of Redis that provides high availability and scalability through partitioning the dataset across multiple nodes. Prerequisites Understanding of Kubernetes Architecture Before diving into deploying Redis Cluster on Kubernetes, it is crucial to have a basic understanding of Kubernetes architecture. This involves knowing the main components of a Kubernetes cluster, such as nodes, pods, and services. Understanding how these ... Read More

Role of Data Structure and Algorithms in Machine Learning

Devang Delvadiya
Updated on 09-Jun-2023 17:00:17
Machine learning is a growing field in technology that has changed many industries, like healthcare and finance. It has helped with things like language processing, image recognition, and making predictions. Data structures and algorithms play an important role in machine learning, helping to solve complex problems. In this article, we will look at the role of data structures and algorithms in machine learning and how they help to solve complex problems. Before we discuss the role of data structures and algorithms in machine learning, it is important to have a clear understanding of what these terms mean. A data structure ... Read More

Sum of frequencies of characters of a string present in another string

Siva Sai
Updated on 18-May-2023 14:12:10
In this article, we are going to explore an interesting problem related to string manipulation in C++. The problem statement is "Sum of frequencies of characters of a string present in another string". This problem provides a great opportunity to enhance your understanding of string operations, character frequency calculation, and the concept of mapping in C++. Problem Statement Given two strings, the task is to find the sum of frequencies of characters of the first string that are present in the second string. C++ Solution Approach To solve this problem, we will first create frequency maps for both strings using ... Read More

string__npos in C++ with Examples

Siva Sai
Updated on 18-May-2023 14:10:08
In this article, we will delve into a specific aspect of string handling in C++: the string::npos constant. string::npos is a static member constant value with the greatest possible value for an element of type size_t. This constant is defined with a value of -1, which, when cast to size_t, gives us the largest possible representation for size_t. In the context of strings in C++, it is generally used to indicate an invalid position. What is String::npos? In C++, string::npos is a constant static member of the std::string class that represents the maximum possible value for the size_t type. It ... Read More

Sort an array of strings in ascending order with each string sorted in descending order

Siva Sai
Updated on 18-May-2023 14:07:45
In this article, we dive into a unique and interesting problem related to arrays and string manipulation in C++. The problem at hand is "Sort an array of strings in ascending order with each string sorted in descending order". This problem is an excellent way to enhance your knowledge of string manipulation, arrays, and sorting algorithms. Problem Statement Given an array of strings, the task is to sort the array in ascending order, but with each string sorted in descending order. C++ Solution Approach We can solve this problem by using the sort function provided by the C++ Standard Library. ... Read More

Remove all occurrences of a word from a given string using Z-algorithm

Siva Sai
Updated on 18-May-2023 14:05:54
This article delves into an interesting string manipulation problem: "Remove all occurrences of a word from a given string using Z-algorithm". This problem serves as an excellent use case for the Z-algorithm, highlighting its efficacy in pattern searching problems. Let's explore in detail. Problem Statement Given a string S and a word W, the task is to remove all occurrences of W from S using the Z-algorithm. Understanding the Problem Consider a string S = "HelloWorldHelloWorld" and a word W = "World". The goal is to remove all occurrences of W from S. Hence, the output would be "HelloHello". Z-algorithm ... Read More
1 2 3 4 5 ... 124 Next
Advertisements