Programming Articles - Page 1781 of 3366

What is the difference between Task.WhenAll() and Task.WaitAll() in C#?

Nizamuddin Siddiqui
Updated on 19-Aug-2020 11:40:59

8K+ Views

The Task.WaitAll blocks the current thread until all other tasks have completed execution. The Task.WhenAll method is used to create a task that will complete if and only if all the other tasks have completed.If we are using Task.WhenAll we will get a task object that isn’t complete. However, it will not block but will allow the program to execute. On the contrary, the Task.WaitAll method call actually blocks and waits for all other tasks to complete.To understand with an example, let us say we have a task that performs some activity with the UI thread say some animation needs ... Read More

Find the cordinates of the fourth vertex of a rectangle with given 3 vertices in Python

Arnab Chakraborty
Updated on 19-Aug-2020 11:38:04

763 Views

Suppose we have a grid of size Q * P, this grid contains exactly three asterisk '*' and every other cell there is dot '.', where '*' is for a vertex of a rectangle. We have to find the coordinates of the missing vertex. Here we will consider 1-based indexing.So, if the input is like grid = [ ".*.", "...", "*.*" ], then the output will be [1, 3], this is the missing coordinate.To solve this, we will follow these steps −p := number of rowsq := number of columnsrow := make a map for all row number, and associated ... Read More

How to download a file from a URL in C#?

Nizamuddin Siddiqui
Updated on 19-Aug-2020 11:37:22

9K+ Views

A file can be downloaded from a URL using web client. It is available in System.Net namespace.The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.The web client can be said as an application or web browser (like Google Chrome, Internet Explorer, Opera, Firefox, Safari) which is installed in a computer and used to interact with Web servers upon user’s request. It is basically a consumer application which collects processed data from servers.A Client and a Server are two parts of a connection, these are two ... Read More

Find the closest element in Binary Search Tree in C++

Farhan Muhamed
Updated on 05-Aug-2025 18:08:53

399 Views

In this article, we will learn to solve a popular problem that involves finding the closest element in a binary search tree (BST) to a given target value. There are two methods to solve this problem: Brute Force Method (Inorder Traversal) Optimized Method (DFS Traversal) Before moving to the solution, let's understand the problem statement in detail. Find the Closest Element in Binary Search Tree Given a binary search tree (BST) and a target value K, the task is to find a node in BST, whose value is ... Read More

How to populate XDocument from String in C#?

Nizamuddin Siddiqui
Updated on 19-Aug-2020 11:35:17

2K+ Views

XML is a self-describing language and it gives the data as well as the rules to identify what information it contains. Like HTML, XML is a subset of SGML - Standard Generalized Markup Language.The XDocument class contains the information necessary for a valid XML document. This includes an XML declaration, processing instructions, and comments.Note that we only have to create XDocument objects if we require the specific functionality provided by the XDocument class. In many circumstances, we can work directly with XElement. Working directly with XElement is a simpler programming model.XDocument derives from XContainer. Therefore, it can contain child nodes. ... Read More

Find the character in first string that is present at minimum index in second string in Python

Arnab Chakraborty
Updated on 19-Aug-2020 11:31:23

362 Views

Suppose we have a string str and another string patt, we have to find determine the character in patt that is present at the minimum index of str. If no character patt1 is present in str1 then return -1.So, if the input is like str = "helloworld" and patt = "wor", then the output will be 'o' as 'o' is present at minimum index in strTo solve this, we will follow these steps −for i in range 0 to size of patt, dofor j in range 0 to size of Str, doif patt[i] is same as Str[j] and j < ... Read More

Find sum of all elements in a matrix except the elements in row and-or column of given cell in Python

Arnab Chakraborty
Updated on 19-Aug-2020 11:30:03

923 Views

Suppose we have a 2D matrix and a set of cell indexes. Cell indices are represented as (i, j) where i is row and j is column, now, for every given cell index (i, j), we have to find the sums of all matrix elements excluding the elements present in ith row and/or jth column.So, if the input is like223457643cell indices = [(0, 0), (1, 1), (0, 1)], then the output will be [19, 14, 20]To solve this, we will follow these steps −n := size of ind_arrans := a new listfor i in range 0 to n, doSum := ... Read More

Find substrings that contain all vowels in Python

Arnab Chakraborty
Updated on 19-Aug-2020 11:28:19

885 Views

Suppose we have a string in lowercase alphabets, we have to find substrings that contain all the vowels at least once and there exist no consonants in that substrings.So, if the input is like "helloworldaeiouaieuonicestring", then the output will be ['aeiou', 'aeioua', 'aeiouai', 'aeiouaiu', 'eioua', 'eiouai', 'eiouaiu']To solve this, we will follow these steps −n := size of sfor i in range 0 to n, domy_map := a new mapfor j in range i to n, doif s[j] not vowel, thencome out from the loopmy_map[s[j]] := 1if size of my_map is same as 5, thendisplay s[from index i to j ... Read More

How to get the name of the current executable in C#?

Nizamuddin Siddiqui
Updated on 19-Aug-2020 11:31:26

5K+ Views

There are several ways to get the name of the current executable in C#.Using System.AppDomain −Application domain provides isolation between code running in different app domains. App Domain is a logical container for code and data just like process and has separate memory space and access to resources. App domain also serves as a boundary like process does to avoid any accidental or illegal attempts to access the data of an object in one running application from another.System.AppDomain class provides us the ways to deal with application domain. It provides methods to create new application domain, unload domain from memory ... Read More

Find subsequences with maximum Bitwise AND and Bitwise OR in Python

Arnab Chakraborty
Updated on 19-Aug-2020 11:26:24

764 Views

Suppose we have an array of n elements, we have to show the maximum sum by choosing two subsequences of the array (they may or may not be different) so that the sum of bit-wise AND operation of all elements of the first subsequence and bit-wise OR operation of all the elements of the second subsequence is maximum.So, if the input is like A = {4, 6, 7, 2}, then the output will be 14 as we are getting maximum AND value by selecting 7 only and maximum OR value by selecting all (4 | 6 | 7 | 2) ... Read More

Advertisements