Found 34494 Articles for Programming

Given a sequence of words, print all anagrams together

Divya Sahni
Updated on 03-Nov-2023 14:52:20

401 Views

Anagrams − An anagram is a word or a phrase formed by rearranging the alphabets of another word or phrase, usually once. Some examples of anagrams are given below − Top - Pot Silent - Listen Post - Stop Dog - God Problem Statement Given an array of words arr[]. For the given array print all the anagrams together. Sample Example 1 Input arr[] = {“star”, “god”, “vile”, “save”, “evil”, “care”, “arts”, “race”, “dog”, “vase”} Output arts star care race dog god evil vile save vase ... Read More

Find the interval which contains the maximum number of concurrent meetings

Divya Sahni
Updated on 03-Nov-2023 14:49:01

191 Views

Given a scenario of a company where meetings are held during fixed time slots. These slots might be overlapping or distant. Thus, optimizing meeting efficiency is important in order to accommodate maximum meetings without any conflicts between schedules. In the problem given, we’ll be going through such an optimizing meeting efficiency problem. Problem Statement Given a two-dimensional array time[][] containing the start time and end time of all the meetings that are scheduled for that day. The task is to find the time interval when most of the meetings are occurring. Sample Example 1 Input: time[][] = {{1, 5}, {2, 6}, {3, 7}, {4, ... Read More

Design an efficient data structure for given operations

Divya Sahni
Updated on 03-Nov-2023 14:45:34

198 Views

In order to design efficient data structures for specific operations, the time and space complexity of the given operations for the data structure created is important. Looking into some basic operations and how they can be efficiently optimized − insert() − Inserts an element to the data structure Dynamic Arrays, Hash Tables, Binary Search Trees and Balanced Search Trees like AVL Trees or Red-Black Trees are the most efficient choice of data structures providing O(1) complexity for insertions operation. delete() − Deletes an element from the data structure Hash tables approach the deletion process in O(1) time while Binary Search Trees and Balanced Search ... Read More

Maximum level sum in N-ary Tree

Divya Sahni
Updated on 03-Nov-2023 14:39:39

259 Views

The N-ary tree is a tree data structure where each node can have a maximum of N children where N is a positive integer (N >= 0). N-ary trees are used in many applications like file systems, organizational charts and syntax trees in programming languages. Example of N-ary tree with N = 4. A / / \ \ B C D E / | \ ... Read More

Show Uniform Discrete Distribution in Statistics using Python

Pranay Arora
Updated on 02-Nov-2023 14:03:34

222 Views

In the field of statistics, there is a major role played by probability distributions in modeling and analyzing various random phenomena. Uniform Discrete Distribution is one of them. It is particularly used when dealing with discrete random variables which have equally likely outcomes. Ahead in this article, we will explore Uniform Discrete Distribution in the light of Python programming, using the scipy.stats.randint() function. Scipy is a powerful python library for scientific analysis and calculations. The stats module provides tools for statistical analysis including probability distributions. The randint() function in the scipy.stats module represents the uniform discrete variable, which inherits its ... Read More

Show Tukey-Lambda Distribution in Statistics using Python

Pranay Arora
Updated on 02-Nov-2023 14:01:33

105 Views

Introduction Statisticians skillfully mesh probability distributions with relevant data sources, thereby lending (or disavowing) plausibility to wide-ranging, though pertinent, hypotheses regarding variable complexities within those databases. In this realm, the Tukey Lambada distribution distinguishes itself via distinct features. With its versatility, the Tukey distribution efficiently models diverse datasets showcasing varied shapes, tails, and degrees of asymmetry. As we dive into Python implementation, it's crucial to understand the Tukey-Lambda distribution's fundamental traits first. Understanding the Tukey-Lambda Distribution In 1960s, John W. Tukey developed the Tukey-Lambda distribution – a statistical constant probability distribution. Flexible enough to accommodate multiple shape variances, this distribution ... Read More

Python - Unique Values Multiplication

Pranay Arora
Updated on 02-Nov-2023 13:04:22

79 Views

List in python allows duplicate entries, that is we can have the same value twice in a list. That is useful in most cases, but sometimes there is a need to remove the duplicate elements to perform certain operations. In this article we will focus on how we can take up the unique values removing duplicates from a list of integers and finding their product. It has a wide use case scenario and we will try and discuss all possible ways to generate the output. Method 1: Set Implementation Set in python is unordered data collection that is iterable, mutable ... Read More

Python - Unique Tuple Frequency (Order Irrespective)

Pranay Arora
Updated on 02-Nov-2023 12:52:03

143 Views

In this article, we will have input as a list of tuples and our goal will be to print the frequency of unique tuples but it will be order irrespective. Order irrespective means that a tuple (1, 2, 3) and (1, 3, 2) will be treated as same even though their order is different. For example, consider the following − Input [(1, 2, 3), (2, 1, 3), (4, 5, 6), (1, 2, 3), (3, 2, 1)] Output 2 Explanation The tuples at index 0, 1, 3 and 4 are same and hence frequency count increases by ... Read More

Python - Uneven Sized Matrix Column Minimum

Pranay Arora
Updated on 02-Nov-2023 13:59:29

84 Views

In Python, when dealing with matrices of uneven row lengths, the efficiency in locating each column's minimum values becomes paramount; a variety of approaches each boasting its own strengths and suitability for different scenarios exist to tackle this task. We are going to delve into several methods within this article: from basic nested loops all the way up to advanced tools such as NumPy and Pandas. Ultimately, you will grasp a comprehensive understanding of two crucial skills: mastering the manipulation of uneven-sized matrices and extracting valuable information from them. Method 1: Using Nested Loops This method, utilizing nested loops, iterates ... Read More

Python - Tuple value product in dictionary

Pranay Arora
Updated on 02-Nov-2023 12:49:07

93 Views

Dictionaries in python are widely used, to store data in key-value pairs. Many times, we get stuck in finding the product of elements in the tuple received as value in the dictionary. This mostly arises in situations working with data manipulation or analysis. Through this article, we will code and understand various ways to unpack the dictionary and calculate the product of tuple elements at each index. Input {'a': (1, 3, 5, 7), 'b': (2, 4, 6, 8), 'c': (2, 3, 5, 7)} Output (4, 36, 150, 392) Method 1: Using Tuple Unpacking and zip() Function ... Read More

Advertisements