Nishu Kumari

Nishu Kumari

Technical Content Engineer

88 Articles Published

Articles by Nishu Kumari

88 articles

C++ Programs To Create Pyramid and Pattern

Nishu Kumari
Nishu Kumari
Updated on 21-Aug-2025 2K+ Views

In this article, we will show you how to write C++ programs to create different pyramids and patterns. You can create many kinds of patterns using stars, numbers, and alphabets. Below is the list of patterns we will cover in this article- Simple Pyramid Pattern in C++ Flipped Simple Pyramid Pattern in C++ Inverted Pyramid Pattern in C++ Flipped Inverted Pyramid Pattern in C++ Triangle Pattern in C++ Inverted Triangle Pattern in C++ ...

Read More

Write a program in C++ to find the length of the largest subarray with zero sum

Nishu Kumari
Nishu Kumari
Updated on 20-Aug-2025 401 Views

We are given an array of N integers and the task is to find the length of the longest subarray whose elements sum up to zero. A subarray is a continuous sequence of elements within the array. If no such subarray exists, return 0. Let's look at a few example scenarios to understand the problem better- Scenario 1- Input: N = 7 arr = {1, 2, -3, 3, -1, 2, -2} Output: 5 Explanation: The subarray {2, -3, 3, -1, 2} has a sum of 0 and its length is 5, which is the longest such ...

Read More

Write a program in C++ to find the maximum and second maximum in a given unsorted array of integers

Nishu Kumari
Nishu Kumari
Updated on 20-Aug-2025 5K+ Views

We are given an array of unsorted integers of size N. The task is to find the distinct maximum and second maximum elements which are present in the array. The array may contain duplicate elements also, so we have to find only distinct elements. If there is no second maximum, we will return -1 for the second maximum. Let's look at some example scenarios to understand the problem clearly - Scenario 1- Input: N = 5, A[] = {2, 2, 1, 3, 4} Output: 4 and 3 Explanation: From the given array, we can see that '4' is ...

Read More

Write a program in C++ to check if a string can be obtained by rotating another string by two places

Nishu Kumari
Nishu Kumari
Updated on 20-Aug-2025 559 Views

We are given two strings, a and b and the task is to find whether we can obtain the string b by rotating string a exactly two places in either an anticlockwise (left) or clockwise (right) direction. Let's take an example scenario to understand the problem clearly — Scenario 1- Input: a = "google", b = "legoog" Output: True Explanation: Rotating "google" two places anticlockwise gives "legoog", which matches string b. Thus, we return True. Scenario 2- Input 2: a = "tuorialst", b = "tutorials" Output: False Explanation: String "tuorialst" cannot be ...

Read More

Write a program in C++ to find the missing positive number in a given array of unsorted integers

Nishu Kumari
Nishu Kumari
Updated on 20-Aug-2025 529 Views

We are given an array of unsorted integers, and the task is to find the missing positive integer. The given array may contain negative numbers, zeros, and duplicate values, all in any random order. Let's look at some example scenarios to understand the problem clearly- Scenario 1- Input: arr = [3, -2, 5, 1, -7, 4, -1, 8] Output: 2 Explanation: The number 2 is not present in the array, so the missing positive is 2 Scenario 2- Input: arr = [0] Output: 1 Explanation: In the given array, '1' is the only positive ...

Read More

How to find the maximum element of a Vector using STL in C++?

Nishu Kumari
Nishu Kumari
Updated on 19-Aug-2025 8K+ Views

A vector in C++ is a dynamic array that stores elements of the same data type and can change its size when needed. In this article, we are given a vector and our goal is to find the maximum (largest) element using different STL methods in C++. Let's understand this with an example: // Example 1 std::vector vec1 = {11, 13, 21, 45, 8}; The largest element is 45. // Example 2 std::vector vec2 = {1, 9, 2, 5, 7}; The largest element is 9. Finding Maximum Element of a Vector Using STL in ...

Read More

C++ Program to Find the Frequency of a Character in a String

Nishu Kumari
Nishu Kumari
Updated on 19-Aug-2025 19K+ Views

A string is a sequence of characters like letters, numbers, symbols, or anything enclosed in double quotes (e.g., "Hello"). Our goal is to find the frequency of a character in a given string, which means counting how many times that specific character appears in the string. Let's look at an example to understand the problem clearly- //Example 1 Input: String: "Tutorialspoint" Character to check: 't' Output: The character 't' appears 3 times in the string. //Example 2 Input: String: "Welcome to Tutorialspoint" Character to check: 'o' Output: The character 'o' appears 4 times in the string. ...

Read More

Write a program in C++ to count the Number of substrings that starts with ‘1’ and ends with ‘1’

Nishu Kumari
Nishu Kumari
Updated on 08-Aug-2025 562 Views

We are given the length of a binary string str and the string itself. The task is to count the number of substrings that start with '1' and end with '1'. A binary string contains only '0's and '1's, and a substring is any continuous part of the given string. Let's look at a few example scenarios to understand the problem clearly: Scenario 1 Input: N = 5, str = "11101" Output: 6 Explanation: In the given binary string, there are 6 substrings that start and end with '1'. These are: ("11", "111", "1110", "11101", "1101", and "101"). Scenario ...

Read More

An in-place algorithm for String Transformation in C++

Nishu Kumari
Nishu Kumari
Updated on 06-Aug-2025 271 Views

We are given a string and need to move all characters at even positions to the end of the string while maintaining the original order of both even-positioned and odd-positioned characters. The transformation should be done in-place (without using extra space) and in O(n) time. Let's look at a few example scenarios to understand the problem clearly. Scenario 1 Input: T1u2t0o6r2i0a0l4s Output: Tutorials12062014 Explanation: Odd-positioned characters are T u t o r i a l s. Even-positioned characters are 1 2 0 6 2 0 1 4. We place the even-positioned characters at the end while keeping their ...

Read More

Arrange consonants and vowels nodes in a linked list in C++?

Nishu Kumari
Nishu Kumari
Updated on 06-Aug-2025 279 Views

A singly linked list is a fundamental data structure that consists of nodes,  where each node contains a data field and a reference to the next node in the linked list. The next of the last node is null, indicating the end of the list. The given task is to rearrange the linked list in such a way that all the vowel nodes precede the consonants while maintaining the order of their arrival. Scenario Input: a -> b-> c -> d-> e-> f-> g-> h-> i Output: a-> e-> i-> b-> c-> d-> f-> g-> h To solve this problem, we ...

Read More
Showing 1–10 of 88 articles
« Prev 1 2 3 4 5 9 Next »
Advertisements