Move all Negative Numbers to Beginning and Positive to End with Constant Extra Space

Suppose you have an array of integers. It consists of both negative and positive numbers and the problem statement asks to shift/move all the negative and positive elements to the left of the array and to the right of the array respectively without using extra space. Example  Input: arr[]={2,4,-10,13,-7,-60,52,8,-19 } …

Read moreMove all Negative Numbers to Beginning and Positive to End with Constant Extra Space

Sorting using trivial hash function

The problem “Sorting using trivial hash function” states that you are given an integer array. An array can be containing both negative and positive numbers. The problem statement asks to sort the array using Trivial Hash Function. Example arr[] = {5,2,1,3,6} {1, 2, 3, 5, 6} arr[] = {-3, -1, …

Read moreSorting using trivial hash function

Reverse a String using Stack

We have given a string s of length n which contains lower case letters, upper case letters, integers, and some special symbol. Reverse the given string using stack. Let’s see some examples for better understanding. Example Input  s = “TutorialCup” Output  puClairotuT Input s = “Stack” Output kcatS Using Stack …

Read moreReverse a String using Stack

Program to Toggle all Characters in a String

Problem Statement In the “Program to Toggle all Characters in a String” problem we have given a string, write a program to toggle all characters of the given string. Here toggle means converting all the uppercase characters to lowercase and all lowercase characters to uppercase characters. Input Format The first …

Read moreProgram to Toggle all Characters in a String