Arnab Chakraborty has Published 4293 Articles

Search in Rotated Sorted Array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 12:55:30

1K+ Views

Consider we have an array sorted in ascending order, and that is rotated at some pivot unknown to you beforehand. For example, [0, 1, 2, 4, 5, 6, 7] might become [4, 5, 6, 7, 0, 1, 2]. We have given a target value to the search. If we can ... Read More

Divide Two Integers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 12:51:59

2K+ Views

Suppose we have two integers dividend and divisor. We have to divide two integers without using multiplication, division, and mod operator. Return the quotient after dividing the dividend by divisor. The integer division should truncate toward zero. Both of the inputs are integersSo if the given inputs are dividend = ... Read More

Swap Nodes in Pairs in C++

Arnab Chakraborty

Arnab Chakraborty

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

849 Views

Consider we have a linked list. We have to swap every two adjacent nodes and return its head. The constraint is that we cannot modify the value of the nodes, only the node itself can be changed. So if the list is like [1, 2, 3, 4], then the resultant ... Read More

Generate Parentheses in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 12:34:31

3K+ Views

Suppose we have a value n. We have to generate all possible well-formed parentheses where n number of opening and closing parentheses are present. So if the value of n = 3, then the parentheses set will be ["()()()", "()(())", "(())()", "(()())", "((()))"]To solve this, we will follow these steps ... Read More

Remove Nth Node From End of List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 12:27:41

693 Views

Suppose we have a linked list. We have to remove the Nth node from the end of the list, then return its head. So if the list is like [1, 2, 3, 4, 5, 6] and n = 3, then the returned list will be [1, 2, 3, 5, 6].To ... Read More

Letter Combinations of a Phone Number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 12:16:20

3K+ Views

Suppose we have a string containing digits from 2-9 inclusive. We have to return all possible letter combinations that the number could represent. One mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.12a b c3d e ... Read More

3Sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 12:04:31

6K+ Views

Suppose we have an array of numbers. It stores n integers, there are there elements a, b, c in the array, such that a + b + c = 0. Find all unique triplets in the array which satisfies the situation. So if the array is like [-1, 0, 1, ... Read More

Integer to Roman in C

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 11:57:00

7K+ Views

Given a decimal number n, we have to convert this into Roman numeral. The value n lies in the range 1 to 4000. These are some Roman Numerals.NumberNumeral1I4IV5V9IX10X40XL50L90XC100C400CD500D900CM1000M4000MMMMSo if the number n = 859, its Roman Numeral will be DCCCLIXTo solve this, we will follow these stepsDefine an array to ... Read More

Container With Most Water in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 11:38:14

431 Views

Suppose we have a set of n non-negative integers a1, a2, ..., an, each value represents a point at coordinate (i, a[i]). n vertical lines are present in such a way that the two endpoints of line i is at (i, a[i]) and (i, a[0]). We have to find two ... Read More

String to Integer (atoi) in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 11:33:17

728 Views

Suppose we have to design a module, that first discards as many whitespace characters as necessary until the first non-whitespace character is reached. After that, starting from this character, it takes an optional initial plus sign or minus sign followed by as many numerical digits, and interprets them as a ... Read More

Advertisements