Server Side Programming Articles

Page 241 of 2109

Program to find out if a linked list is present in a given binary tree in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 278 Views

Suppose we are given a binary tree that has a root node 'root' and a linked list that has a head node 'head'. We have to find out if that linked list exists in that binary tree. If a set of nodes in the tree have links with each other in order as a linked list, and if that order is similar to that of the provided linked list, then we return 'True' or otherwise, we return 'False'. So, if the input is like ? 6 ...

Read More

Python Pandas - Return TimeDeltaIndex as object ndarray of datetime.datetime objects

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 170 Views

To return TimeDeltaIndex as object ndarray of datetime.timedelta objects, use the TimeDeltaIndex.to_pytimedelta() method. This method converts Pandas timedelta objects to Python's native datetime.timedelta objects. Syntax TimedeltaIndex.to_pytimedelta() Creating a TimeDeltaIndex First, let's create a TimeDeltaIndex object with various timedelta formats − import pandas as pd # Create a TimeDeltaIndex object with different timedelta formats tdIndex = pd.TimedeltaIndex(data=['10 day 5h 2 min 3us 10ns', '+22:39:19.999999', ...

Read More

Python Pandas - Return a dataframe of the components of the TimedeltaIndex

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 198 Views

The TimedeltaIndex.components property in Pandas returns a DataFrame containing the individual components (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) of each timedelta in the index. Creating a TimedeltaIndex First, let's create a TimedeltaIndex with various time durations ? import pandas as pd # Create a TimedeltaIndex with different time formats tdIndex = pd.TimedeltaIndex(data=['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', ...

Read More

Python Pandas - Extract the Number of nanoseconds for each element from TimeDeltaIndex

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 168 Views

To extract the number of nanoseconds for each element from a TimeDeltaIndex object, use the TimedeltaIndex.nanoseconds property. This property returns only the nanosecond component (0-999) from each timedelta, not the total nanoseconds. Syntax TimedeltaIndex.nanoseconds Creating a TimeDeltaIndex First, let's create a TimeDeltaIndex with various time components including nanoseconds ? import pandas as pd # Create a TimeDeltaIndex object with timedelta-like data tdIndex = pd.TimedeltaIndex(data=['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', ...

Read More

Python Pandas - Extract the Number of microseconds for each element from TimeDeltaIndex

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 162 Views

To extract the number of microseconds for each element from TimeDeltaIndex object, use the TimedeltaIndex.microseconds property. This property returns an Int64Index containing the microsecond component of each timedelta. Creating a TimeDeltaIndex First, let's create a TimeDeltaIndex object with various timedelta formats ? import pandas as pd # Create a TimeDeltaIndex object with different timedelta formats tdIndex = pd.TimedeltaIndex(data=['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', ...

Read More

Python Pandas - Extract the Number of seconds for each element from TimeDeltaIndex

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 228 Views

To extract the number of seconds for each element from TimeDeltaIndex object, use the TimedeltaIndex.seconds property. This property returns the seconds component (0-59) of each timedelta element. Creating a TimeDeltaIndex First, let's create a TimeDeltaIndex with various time intervals ? import pandas as pd # Create a TimeDeltaIndex object with different time intervals tdIndex = pd.TimedeltaIndex(data=['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', ...

Read More

Program to find length of longest repeating substring in a string in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 3K+ Views

A repeating substring is a substring that occurs at least twice in a string. In this tutorial, we'll find the length of the longest repeating substring using Python's suffix array approach. So, if the input is like s = "abdgoalputabdtypeabd", then the output will be 3, because the longest substring that occurs more than once is "abd". Algorithm Overview To solve this problem, we will follow these steps − Generate all suffixes of the string Sort the suffixes lexicographically Find the longest common prefix between adjacent suffixes Return the maximum length found Helper ...

Read More

Program to find length longest prefix sequence of a word array in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 283 Views

Suppose we have a list of words called w, with lowercase strings. We have to find the length of the longest sequence of w where each previous word is the prefix of the next word and the next word has just one new character appended. So, if the input is like w = ["pqr", "pq", "m", "mn", "pqrs"], then the output will be 3 because we can get the sequence: ["pq", "pqr", "pqrs"], whose length is 3. Algorithm To solve this, we will follow these steps − Sort the list w ...

Read More

Program to find length of longest consecutively increasing substring in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 295 Views

Given a lowercase string containing English letters and "?" symbols, we need to find the length of the longest consecutively increasing substring that starts with letter "a". For each "?" we can either remove it or replace it with any lowercase letter. For example, if the input is s = "vta???defke", we can transform it into "vtabcdefke" where "abcdef" is the longest consecutively increasing substring starting with "a", giving us a length of 6. Algorithm We'll use a greedy approach to track the current sequence length and question marks ? maxlen − Maximum length found ...

Read More

Program to find length of longest consecutive sublist with unique elements in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 423 Views

Suppose we have a list of numbers called nums, where all elements are unique. We have to find the length of the longest sublist that contains consecutive elements. So, if the input is like nums = [3, 6, 7, 5, 4, 9], then the output will be 5, because the sublist [3, 6, 7, 5, 4] contains all consecutive elements from 3 to 7. Algorithm Approach To solve this, we will follow these steps − Initialize ret := 0 to store the maximum length For each starting ...

Read More
Showing 2401–2410 of 21,090 articles
« Prev 1 239 240 241 242 243 2109 Next »
Advertisements