Arnab Chakraborty has Published 4293 Articles

Program to define set data structure without using library set class in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:51:20

303 Views

Suppose we want to implement a set data structure with the following methods −Constructor to construct a new instance of a setadd(val) to insert integer val into the setexists(val) to check whether val is in the set or notremove(val) to remove the val from the setSo, if we construct a ... Read More

Program to check whether all can get a seat or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:48:20

597 Views

Suppose we have a number n, there are n number of people searching for a seat, we also have a list of bits where 1 represents an already occupied seat and 0 represents empty seat. No two people can sit next to each other, so we have to check whether ... Read More

Program to implement run length string decoding iterator class in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:44:59

240 Views

Suppose we want to define an iterator class that constructs with a run-length encoded lowercase string say s, there are two functions for this iterator they are −next() this finds the next element in the iteratorhasnext() this checks whether the next element is present or notSo, if the input is ... Read More

Program to count operations to remove consecutive identical bits in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:38:03

237 Views

Suppose we have a binary string s, now let us consider an operation where we select a bit and flip its value from 0 to 1 or vice-versa. We have to find the minimum number of operations needed to get a string with no three identical consecutive bits.So, if the ... Read More

Program to define data structure that supports rate limiting checking for user in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:35:16

125 Views

Suppose we want to develop a data structure that can build up with an expire time, and supports a function that takes user id and a timestamp. This will check whether a user with given user_id at time given timestamp the request fails or not. It will fail only when ... Read More

Program to define data structure that supports range sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:31:56

220 Views

Suppose we want to develop a data structure that can build up with a list of integers, and there is a function to find sum of elements from index i to index j-1 whenever we require in an efficient way. There are two functions.Constructor that constructs a new instance with ... Read More

Python Pandas - Return a new Timedelta with seconds floored resolution

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 06:01:43

174 Views

To return a new Timedelta floored to this resolution, use the timedelta.floor() method. For seconds floored resolution, set the freq parameter to the value S.At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('4 ... Read More

Python Pandas - Return a new Timedelta with minutely floored resolution

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 06:00:24

72 Views

To return a new Timedelta floored to this resolution, use the timedelta.floor() method. For minutely floored resolution, set the freq parameter to the value T.At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('8 ... Read More

Python Pandas - Return a new Timedelta with hourly floored resolution

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 05:59:03

85 Views

To return a new Timedelta floored to this resolution, use the timedelta.floor() method. For hourly floored resolution, set the freq parameter to the value H.At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('4 ... Read More

Python Pandas - Return a new Timedelta with daily floored resolution

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 05:57:29

101 Views

To return a new Timedelta floored to this resolution, use the timedelta.floor() method. For daily floored resolution, set the freq parameter to the value D.At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('5 ... Read More

Advertisements