Arnab Chakraborty has Published 4293 Articles

ZigZag Conversion in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 11:25:10

1K+ Views

Suppose the string is like " IWANTTOLEARNCODE". This string is written in a zigzag way on a given number of rows say n. So the pattern is looking like thisITAOWNOERCDALNEWhen we read the line like − "ITAOWNOERCDALNE"So we have to create one module that can perform this kind of operation ... Read More

Longest Palindromic Substring in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 11:19:01

11K+ Views

Suppose we have a string S. We have to find the longest palindromic substring in S. We are assuming that the length of the string S is 1000. So if the string is “BABAC”, then the longest palindromic substring is “BAB”.To solve this, we will follow these stepsDefine one square ... Read More

Decrypt String from Alphabet to Integer Mapping in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 09:18:50

782 Views

Suppose we have a string s that is formed by digits ('0' - '9') and '#'. We have to map s to one English lowercase characters as follows −Characters ('a' to 'i') are represented by ('1' to '9') respectively.Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.We have ... Read More

Convert Binary Number in a Linked List to Integer in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 09:16:41

814 Views

Suppose we have one ‘head’ which is a reference node to a singly-linked list. The value of each node present in the linked list is either 0 or 1. This linked list stores the binary representation of a number. We have to return the decimal value of the number present ... Read More

Shift 2D Grid in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 09:14:50

613 Views

Suppose we have one 2D grid of size m x n. We have another variable k. We have to shift the grid k times. The shift operation will be as followsElement at grid G[i, j] moves to G[i, j + 1]Element at grid G[i, n – 1] moves to G[i ... Read More

Non-decreasing Array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 09:12:39

1K+ Views

Suppose we have an array with n integers, our task is to check whether it could become nondecreasing by modifying at most one element. We can define an array is non-decreasing if it satisfies this rule: array[i] 0if arr[i - 1] > arr[i + 1], then arr[i + 1] ... Read More

Play with Chips in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 09:10:14

406 Views

Suppose there are some chips, the i-th chip is at present at position chips[i]. We can perform any of the two following types of operations any many numbers of times as we want (possibly zero) on any chip −Move the i-th chip by 2 units to the left side or ... Read More

Maximize Sum Of Array After K Negations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 09:06:24

358 Views

Suppose we have an array A of integers, we have to modify the array in the following way −We can choose an i and replace the A[i] with -A[i], and we will repeat this process K times. We have to return the largest possible sum of the array after changing ... Read More

Merge Two Binary Trees in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 08:59:01

744 Views

Suppose we have two binary trees and consider that when we put one of them to cover the other, some nodes of the two trees are overlapped while the others are overlapping. We have to merge them into a new binary tree. The merge rule is like that if two ... Read More

Shortest Unsorted Continuous Subarray in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 08:55:20

323 Views

Suppose we have an integer array, we need to find one continuous subarray such that, if we only sort that subarray in ascending order, then the whole array will be sorted too. We need to find the shortest such subarray and output its length. So if the array is [2, ... Read More

Advertisements