Found 33676 Articles for Programming

Send SMS updates to mobile phone using python

Hafeezul Kareem
Updated on 11-Jul-2020 06:49:54

2K+ Views

In this tutorial, we are going to learn how to send SMS in Python. We will be using Twilio for sending SMS.First of all, go the Twilio and create an account. You will get free trial account. And finish settings.We have to install a module called twilio to work with Twilio client. Install it with the following command.pip install twilioNow, go to the Twilio Documentation on how to send SMS using Twilio client. Or follow the steps to send the SMS.Import the twilio Client from twilio.rest.Get and store the account_sid and auth_token from the your Twilio account.Make instance of the ... Read More

self in Python class

Hafeezul Kareem
Updated on 11-Jul-2020 06:47:23

1K+ Views

In this tutorial, we are going to learn about the self in Python. You must be familiar with it if you are working with Python. We will see some interesting things about.Note − self is not a keyword in Python.Let's start with the most common usage of self in Python.We'll use self in classes to represent the instance of an object. We can create multiple of a class and each instance will have different values. And self helps us to get those property values within the class instance. Let's see ane example.Example# class class Laptop:    # init method   ... Read More

Maximum Sum Decreasing Subsequence in C++

Revathi Satya
Updated on 22-May-2024 11:57:17

402 Views

In this article, we are given an array arr[] of N integers. Our task is to find the Maximum Sum Decreasing Subsequence in C++. A Maximum Sum Decreasing Subsequence (MSDS) is a subsequence of a given sequence of array. Here the sequence elements are ordered in decreasing arrangement and the sum of these elements is the highest. Here, given a sequence of array a1, a2, …, an, the goal is to find a subsequence ai1, ai2, …, aik, where i1>i2>…>i1, such that we say the subsequence is ai1>ai2>…>aik (ordered in a decreasing order). The sequence of terms ai1+(ai2)...+(aik) is ... Read More

Maximum sum Bi-tonic Sub-sequence in C++

Ayush Gupta
Updated on 15-Oct-2020 13:56:52

200 Views

In this problem, we are given an array arr[]. Our task is to create a program to find the maximum sum Bi-tonic subsequence in C++.Bi-tonic subsequence is a special sequence whose elements first increase and then decrease.Let’s take an example to understand the problem, Inputarr[] = {4, 2, 3, 7, 9, 6, 3, 5, 1}Output33ExplanationThe Bi-tonic subsequence which gives the largest sum is {2, 3, 7, 9, 6, 5, 1} Sum = 2 + 3 + 7 + 9 + 6 + 5 + 1 = 33Solution ApproachTo find the maximum sum bitonic subsequence, we will create two arrays, incSeq[] ... Read More

Maximum sum bitonic subarray in C++

Ayush Gupta
Updated on 15-Oct-2020 14:00:02

593 Views

In this problem, we are given an array arr[]. Our task is to create a program to find the maximum sum bitonic subarray in C++.Bitonic Subarray is a special subarray in which the element strictly increase first and then strictly decreases after reaching a certain point.Let’s take an example to understand the problem, Inputarr[] = {4, 2, 3, 7 ,9, 6, 3, 5, 1}Output30ExplanationThe bitonic subarray is [2, 3, 7, 9, 6, 3]. Sum = 2 + 3 + 7 + 9 + 6 + 3 = 30Solution ApproachThe solution is similar to that in the bitonic subsequence problem. We ... Read More

Maximum sum and product of the M consecutive digits in a number in C++

Revathi Satya
Updated on 22-May-2024 11:55:01

349 Views

In this article, we are given a string representing a number. Our task is to create a program in C++ to find the maximum sum and product of M consecutive digits from the given number. We find all sequences of M consecutive digits and return the maximum sum and product. In mathematics, consecutive numbers are defined as those numbers that follow each other in increasing order from the smallest to the largest, with no missing numbers in between. This problem can be iterated through the string representation of the number, in other words, we consider consecutive segments of the length ... Read More

Maximum sum alternating subsequence in C++

Ayush Gupta
Updated on 10-Jul-2020 14:20:34

140 Views

In this tutorial, we will be discussing a program to find maximum sum alternating subsequence.For this we will be provided with an array of integers. Our task is to find the maximum sum of an alternating subsequence i.e sequence which is first decreasing, then increasing, then decreasing and so on.Example Live Demo#include using namespace std; //returning maximum sum alternating series int maxAlternateSum(int arr[], int n) {    if (n == 1) return arr[0];    int dec[n];    memset(dec, 0, sizeof(dec));    int inc[n];    memset(inc, 0, sizeof(inc));    dec[0] = inc[0] = arr[0];    int flag = 0 ;    for (int i=1; i

Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST in C++

Ayush Gupta
Updated on 10-Jul-2020 14:18:26

200 Views

In this tutorial, we will be discussing a program to find maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST.For this we will be provided with a binary tree. Our task is to print the sum of a sub-tree which is also a binary search tree.Example Live Demo#include using namespace std; //creating binary tree node struct Node {    struct Node* left; struct Node* right; int data;    Node(int data) {       this->data = data;       this->left = NULL;       this->right = NULL;    } }; struct Info ... Read More

Maximum subsequence sum such that no three are consecutive

Ayush Gupta
Updated on 10-Jul-2020 14:15:14

352 Views

In this tutorial, we will be discussing a program to find maximum subsequence sum such that no three are consecutive.For this we will be provided with a series of positive integers. Our task is to find the maximum sum without taking in their consecutive positive integers in the sum value.Example Live Demo#include using namespace std; //returning maximum subsequence without involving //three consecutive numbers int maxSumWO3Consec(int arr[], int n) {    int sum[n]; if (n >= 1) sum[0] = arr[0];    if (n >= 2) sum[1] = arr[0] + arr[1];    if (n > 2) sum[2] = max(sum[1], max(arr[1] + arr[2], ... Read More

Maximum sub-matrix area having count of 1’s one more than count of 0’s in C++

Ayush Gupta
Updated on 10-Jul-2020 14:13:32

106 Views

In this tutorial, we will be discussing a program to find maximum sub-matrix area having count of 1’s one more than count of 0’s.For this we will be provided with a matrix containing 0’s and 1’s. Our task is to get the sub-matrix of maximum area containing more 1’s than 0’sExample Live Demo#include using namespace std; #define SIZE 10 //finding length of longest sub-matrix int lenOfLongSubarr(int arr[], int n, int& start, int& finish) {    unordered_map um;    int sum = 0, maxLen = 0;    for (int i = 0; i < n; i++) {       sum ... Read More

Advertisements