 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Server Side Programming Articles - Page 815 of 2650
 
 
			
			336 Views
To find the start time for the given Period object, use the period.start_time property. At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objectsperiod1 = pd.Period("2020-09-22") period2 = pd.Period(freq="D", year = 2021, month = 2, day = 14, hour = 2, minute = 35)Display the Period objectsprint("Period1...", period1) print("Period2...", period2)Get the start time from two Period objectsres1 = period1.start_time res2 = period2.start_timeExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2020-09-22") period2 = pd.Period(freq="D", year ... Read More
 
 
			
			218 Views
Suppose we are provided a binary tree. We have to find out if there exist binary search trees (BST) in the subtrees of it and find out the sum of the largest BST. To find out the sum, we add the values of each node in that BST. We return the sum value as output.So, if the input is likethen the output will be 12.The BST in the given binary tree is −sum of the nodes = 12.To solve this, we will follow these steps −c := 0m := nullvalue := 0Define a function recurse() . This will take nodeif ... Read More
 
 
			
			177 Views
Suppose we are given a binary tree. We have to find out the largest subtree from the tree that is a binary search tree (BST). We return the root node of the BST.So, if the input is likethen the output will be −To solve this, we will follow these steps −c := 0m := nullDefine a function recurse() . This will take nodeif node is not null, thenleft_val := recurse(left of node)right_val := recurse(right of node)count := negative infinityif (node.left is same as null or node.left.val
 
 
			
			391 Views
Suppose we are given a list containing several integer numbers. We have to find out the difference between each pair of values in the array and find out the k-th smallest difference number. The index starts at 0 and the value k is given to us as input.So, if the input is like numbers = {2, 6, 4, 8}, k = 2, then the output will be 2.The differences between the pairs are −(2, 6) = 4(2, 4) = 2(2, 8) = 6(6, 4) = 2(6, 8) = 2(4, 8) = 4If we sort the values, it becomes 2, 2, ... Read More
 
 
			
			251 Views
Suppose we are given two lists, p and q that contain some integer numbers. We have to multiply all the values of these lists and have to find out the k-th largest value from the multiplication results.So, if the input is like p = [2, 5], q = [6, 8], k = 2, then the output will be 16.The multiplication results are: 2 * 6 = 12, 2 * 8 = 16, 5 * 6 = 30, 5 * 8 = 40. The 2nd largest element at is (index starts from 0) is 16.To solve this, we will follow these ... Read More
 
 
			
			547 Views
Suppose we are given a list that contains values in pairs of (m, c). These values represent a line, where y = mx + c. We are also given two values, l, and r. We have to find out the number of the lines that intersect with each other between the range x = l to x = h.So, if the input is like input_list = [[4, 6], [-6, 10], [8, 12]], l = 0, h = 2, then the output will be 2.If we look at the given photo, the lines 4x + 6 = 0 and -6x + ... Read More
 
 
			
			345 Views
Suppose we are given a positive integer number. We have to spell the number in words; like if a number "56" is given as input the output will be "Fifty-Six". The range of conversion is up to a billion.So, if the input is like input = 5678, then the output will be Five Thousand Six Hundred Seventy-Eight.To solve this, we will follow these steps −Define an array ‘numbers’ that contain pairs such as − {{"Billion", 1000000000}, {"Million", 1000000}, {"Thousand", 1000}, {"Hundred", 100}, {"Ninety", 90}, {"Eighty", 80}, {"Seventy", 70}, {"Sixty", 60}, {"Fifty", 50}, {"Forty", 40}, {"Thirty", 30}, {"Twenty", 20}, {"Nineteen", 19}, ... Read More
 
 
			
			173 Views
Suppose we are given a list of cities and a list of roads that connect each other. The list 'cities' contain the name of cities that a tour bus visits in order. In the list 'roads' the roads are listed in a (source, destination) order meaning there is a one-way road from source to destination. Now, there is a problem that some city names in the list 'cities' may be misspelled. We have to correct such misspelled city names by changing the minimum number of characters. We return the number of characters changed as output.So, if the input is like ... Read More
 
 
			
			185 Views
Use the to_series() method to create a series from TimeDeltaIndex in Pandas.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter −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'])Convert TimeDeltaIndex to Series −print("TimeDeltaIndex to series...", tdIndex.to_series()) ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the 'data' parameter 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']) # ... Read More
 
 
			
			222 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