Arnab Chakraborty has Published 4293 Articles

Longest Palindrome in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:41:32

2K+ Views

Suppose we have a string which consists of lowercase or uppercase letters, we have to find the length of the longest palindromes that can be built with those letters. Now the string is case sensitive, so "Aa" is not considered a palindrome here.So, if the input is like "abccccdd", then ... Read More

Convert a Number to Hexadecimal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:38:58

3K+ Views

Suppose we have an integer; we have to devise an algorithm to convert it to hexadecimal. For negative numbers we will use the two’s complement method.So, if the input is like 254 and -12, then the output will be fe and fffffff4 respectively.To solve this, we will follow these steps ... Read More

Find the Difference in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:37:19

360 Views

Suppose we have two strings s and t which consist of only lowercase letters. Now, string t is generated by random shuffling string s and then add one more letter at a random index. We have to find the letter that was added in t.So, if the input is like ... Read More

Guess Number Higher or Lower in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:36:04

608 Views

Suppose we are playing the Guess Game. The properties of this game is as follows −Player 1 will pick a number from 1 to n. player2 have to guess which number I picked. Every time player2 guess wrong, player1 will tell player2 whether the number is higher or lower.We can ... Read More

Intersection of Two Arrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:34:03

2K+ Views

Suppose we have two arrays; we have to find their intersections.So, if the input is like [1, 5, 3, 6, 9], [2, 8, 9, 6, 7], then the output will be [9, 6]To solve this, we will follow these steps −Define two maps mp1, mp2Define an array resfor x in ... Read More

Power of Four in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:31:41

178 Views

Suppose we have an integer; we have to check whether that is a power of 4 or not.So, if the input is like 16, then the output will be True.To solve this, we will follow these steps −if num < 0, then −return falseif num & (num - 1) is ... Read More

Nim Game in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:30:49

1K+ Views

Suppose we are playing a game called, Nim Game with another player. There is a heap of stones, each time one player takes turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. Player1 will take the first turn to remove the ... Read More

Word Pattern in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:28:29

546 Views

Suppose we have a pattern and a string str, find if str follows the same pattern. Here follow means there is a bijection between a letter in pattern and a non-empty word in str.So, if the input is like pattern = "cbbc", str = "word pattern pattern word", then the ... Read More

Implement Stack using Queues in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:26:38

3K+ Views

Suppose we want to implement one stack using a queue. We have to define these methods for the stack.push(x) − Push x onto stack.pop() − Delete and return top element from stacktop() − Return the top element from stack.empty() − Return whether the stack is empty or not.So, if we ... Read More

Contains Duplicate II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Jun-2020 12:24:55

241 Views

Suppose we have an array and an integer k, we have to check whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.So, if the input is like [1, 2, 4, ... Read More

Advertisements