Server Side Programming Articles - Page 1912 of 2650

Letter Combinations of a Phone Number in Python

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 f4g h i5j k l6m n o7p q r s8t u v9w x y z*0#For an example, if the given string is “23”, then the possible strings will be [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”]To solve this, we will follow these steps −Define an array called solve ... Read More

3Sum Closest in C++

Aman Kumar
Updated on 29-Jul-2025 15:18:00

1K+ Views

The 3 Sum Closest problem involves finding the sum of three numbers in an array that is closest to a given target value. We are given an integer array nums of length n and an integer target. Our goal is to find three integers in the array such that their sum is as close as possible to the target using C++ program. In this task, we assume that each input has exactly one solution. If there are multiple sums equally close to the target, we return the maximum one. Let's consider the following example scenario to understand the problem more ... Read More

3Sum in Python

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, 2, -1, -4], then the result will be [[-1, 1, 0], [-1, -1, 2]]To solve this, we will follow these steps −Sort the array nums, and define an array resfor i in range 0 to length of nums – 3if i > 0 and nums[i] = nums[i - 1], then ... Read More

Integer to Roman in C

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 store numeral and corresponding values for the given list. That is called nume arraywe are using a recursive approach, the function decToRom() is used. this is taking nume array and the number num.The decToRom() will be likeif num is not 0, thenmax := find maximum value from nume array that ... Read More

Container With Most Water in Python

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

441 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 lines, which together with x-axis forms one container, so our goal is to find two columns where water volume is max. So if the array is like [1, 8, 6, 2, 5, 4, 8, 3, 7], then it will beIn the shaded part, the height is 7 and there are ... Read More

iswblank() function in C++ STL

Sunidhi Bansal
Updated on 27-Feb-2020 05:44:24

143 Views

The iswblank () function in C++ is used to check if the given wide character is blank not. It is present in “ctype.h” header file in C language and “cctype” header file in C++ Standard template library (STL).Syntax of iswblank is as followsint iswblank(wint_t ch)Return Type − returns non zero value if it contains blank spaces and value 0 if it doesn’t.Parameters − ch − This is the character to be checked.ExampleInput − string str = “I Love Myself”Output − total number of spaces is − 2Input − string str = “Myself”Output − total number of spaces is − 0Approach used ... Read More

Declare a C/C++ function returning pointer to array of integer function pointers

Sunidhi Bansal
Updated on 27-Feb-2020 05:41:36

478 Views

With given array the task is to create a function which will return pointer to an array of integer function pointers.For that we will input the two values and call a function which compares both the two values and functions pointer which return the memory address of bigger value and print it as a result. The function pointer is used to pass address of different function at different times thus making the function more flexible and abstract. So function pointers can be used to simplify code by providing a simple way to select a function to execute based on run-time ... Read More

Isupper() and Islower() and their application in C++

Sunidhi Bansal
Updated on 27-Feb-2020 05:48:09

6K+ Views

The functions isupper() and islower() in C++ are inbuilt functions present in “ctype.h” header file. It checks whether the given character or string is in uppercase or lowercase.What is isupper()?This function is used to check whether the given string contains any uppercase letter or not and also if we have one character as an input then it checks whether the character is in uppercase or not.Syntaxint isupper ( int arg)ExplanationThis function has return type as int as it returns non zero value when the string contains uppercase letter and 0 otherwise. It has one parameter which will contain the character ... Read More

DEQUE CBEGIN() in C++

Sunidhi Bansal
Updated on 30-Jan-2020 10:03:30

179 Views

Given the task is to show the working of deque::cbegin() in C++ STL.What is Deque::cbegin( ) function?deque::cbegin() is a function which comes under deque header file, cbegin() returns the iterator pointer which points to the first element of the deque container.Note − cbegin() function does not have any arguments in it.Syntaxdeq.cbegin();Where deq is the deque’s object.Return ValueThe function returns a const_iterator.const_iterator is a random access iterator which is used to point to the first element of the deque container. We can traverse the whole container using the first element of the container, but this can’t be used to do the ... Read More

DEQUE CRBEGIN() in C++

Sunidhi Bansal
Updated on 30-Jan-2020 07:42:23

201 Views

Given the task is to show the working of deque::crbegin() in C++.Deque is a double ended queue that gives insertion and deletion at each end i.e. front and back with high performance, in contrast to vector that gives high performance insertion at the end i.e. back only.Also, it provides random access to components too. Though one can insert part in between alternative components in dequeue with insert(), however its performance won't be sensible rather like a vector.What is deque::crbegin()?Deque::crbegin(), where crbegin is the constant reverse begin, implies it constantly reverse the begin or in other words it returns the constant_reverse_iterator.What ... Read More

Advertisements