Dev Prakash Sharma has Published 548 Articles

Update the bit in the given position or Index of a number using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:56:21

2K+ Views

In the given problem, we have to update the bit of the given index of a number. To update the number, we can use Bit Manipulation operation on a given number. For example, Input-1 −N= 25 bit= 1 position= 2Output −29Explanation − Since the given input 25 can be written ... Read More

static_assert in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:55:01

401 Views

static_assert is a function which is useful for programmers to print the error in the screen after compiling the program without messing up with the output too much.Earlier in C++11 and C++14, static_assert had different functionality which means we have to write our own message while defining the static_assert. However, ... Read More

Square of a sorted array in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:54:29

2K+ Views

In the given array of sorted integers, the task is to print the squares of every array element and print the array in sorted order. For example, Input-1 −arr[ ] = { -3, -1, 0, 1, 4, 6 };Output −{0, 1, 1, 9, 16, 36}Explanation − The squares of each ... Read More

Sort an arrays of 0’s, 1’s and 2’s using Java

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:53:48

387 Views

Given an array of 0, 1 and 2 sort the element in an order such that all the zeros come first before 1 and all the 2’s in the end. We have to sort all the elements of the array in-place.We can solve this problem using DNF (Dutch National Flag) ... Read More

Sort an arrays of 0’s, 1’s and 2’s using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:53:04

944 Views

Given an array of 0, 1, and 2, sort the elements in an order such that all the zeros come first before 1 and all the 2’s in the end. We have to sort all the elements of the array in-place.We can solve this problem using DNF (Dutch National Flag) ... Read More

Significance of Lambda Function in C/C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:51:35

4K+ Views

Lambda Function − Lambda are functions is an inline function that doesn’t require any implementation outside the scope of the main program.Lambda Functions can also be used as a value by the variable to store. Lambda can be referred to as an object that can be called by the function ... Read More

Search an element in the given singly Linked List using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:50:20

564 Views

Given a singly linked list, the task is to search a particular element in the linked list. If the element is found, then print “present” otherwise “Not present”. For example, Input-1 −1→ 2→ 3→ 4→ 5→ 6Searching for ‘7’Output −Not PresentExplanation − In the given singly linked list the element ... Read More

Write a program in Java to rotate a matrix by 90 degrees in anticlockwise direction

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:49:35

2K+ Views

Let’s suppose we have given a square matrix of N×N. The task is to rotate the matrix counterclockwise. For example, Input-1 −N = 3 matrix[ ][ ] = [    [1 2 3],    [4 5 6],    [7 8 9] ]Output −3 6 9 2 5 8 1 4 ... Read More

Reverse Vowels of a string in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:49:03

2K+ Views

Given a string, the task is to reverse all the vowels present in the given string. For example, Input-1 −a = “tutor”Output −toturExplanation − Reversing the string “tutor” will generate the output as “totur.Input-2 −a = “mathematics”Output −mithametacsExplanation − Reversing the string “mathematics” will generate the output as “mithametacs”.Approach to ... Read More

Write a program in C++ to replace all the 0’s with 5 in a given number

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:48:02

1K+ Views

Given an integer N, the task is to replace all the 0’s that appear in the number with ‘5’. However, the number with leading ‘0’ cannot be replaced with ‘5’ as it remains unchanged. For example, Input-1 −N= 1007Output −1557Explanation − The given number has 2 zeros which when replaced ... Read More

Advertisements