
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

213 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 likeTreeLinked Listthen the output will be True.To solve this, we will follow these steps −arr := a new ... Read More

123 Views
To return TimeDeltaIndex as object ndarray of datetime.datetime objects, use the TimeDeltaIndex.to_pytimedelta() method.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Return TimeDeltaIndex as object ndarray −print("Return TimeDeltaIndex as object ndarray of datetime.datetime objects...", tdIndex.to_pytimedelta())ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the 'data' parameter as well tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min ... Read More

144 Views
To return a dataframe of the components of the TimedeltaIndex, use the TimedeltaIndex.components property.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Display TimedeltaIndex −print("TimedeltaIndex...", tdIndex) Return a dataframe of the components of TimeDeltas. The components include days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds −print("The Dataframe of the components of TimeDeltas...", tdIndex.components)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have ... Read More

114 Views
To extract the number of microseconds for each element from TimeDeltaIndex object, use the TimedeltaIndex.nanoseconds property.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Display the number of nanoseconds from each element of TimeDeltaIndex −print("The number of nanoseconds from the TimeDeltaIndex object...", tdIndex.nanoseconds)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the 'data' parameter as ... Read More

111 Views
To extract the number of microseconds for each element from TimeDeltaIndex object, use the TimedeltaIndex.microseconds property.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Display TimedeltaIndex −print("TimedeltaIndex...", tdIndex) Display the number of microseconds from each element of TimeDeltaIndex −print("The number of microseconds from the TimeDeltaIndex object...", tdIndex.microseconds)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using ... Read More

166 Views
To extract the Number of seconds for each element from TimeDeltaIndex object, use the TimedeltaIndex.seconds propertyAt first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Display TimedeltaIndex −print("TimedeltaIndex...", tdIndex)Display the number of seconds from each element of TimeDeltaIndex −print("The number of seconds from the TimeDeltaIndex object...", tdIndex.seconds)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the ... Read More

3K+ Views
Suppose we have a lowercase string s, we have to find the length of the longest substring that occurs at least twice in s. If we cannot find such string, return 0.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".To solve this, we will follow these steps −Define a function lcs() . This will take s1, s2n := minimum of size of s1 and size of s2for i in range 0 to n - 1, doif s1[i] is not same as s2[i], thenreturn ... Read More

235 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.To solve this, we will follow these steps −sort the list wdp := a map, where default value for a key is 0res := 0for ... Read More

286 Views
Suppose we have a binary matrix, where 0 indicates empty cell and 1 indicates wall. We can start at any empty cell on first row and want to end up on any empty cell on the last row. We can move left, right, or down, we have to find the longest such path where we can visit each cell at most once. If this is not possible, then return 0.So, if the input is like000000010000then the output will be 10, as We can move (0, 3), (0, 2), (0, 1), (0, 0), (1, 0), (1, 1), (1, 2), (2, 2), ... Read More

528 Views
Suppose we have a list of numbers called nums, we have to find the maximum length of a contiguous strictly increasing sublist. We are allowed to remove at most single element from the list.So, if the input is like nums = [35, 5, 6, 7, 8, 9, 12, 11, 26], then the output will be 7, because if we remove 12 from nums, the list will be [5, 6, 7, 8, 9, 11, 26], the length is 7, this is the longest, contiguous, strictly increasing sub-list.To solve this, we will follow these steps −if nums is empty, thenreturn 0end := ... Read More