
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 26504 Articles for Server Side Programming

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

529 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

228 Views
Suppose we have a lowercase string s. This contains English letters as well as "?" Symbol. For each "?" we must either remove it or replace it with any lowercase letter. We have to find the length of the longest consecutively increasing substring that starts with letter "a".So, if the input is like s = "vta???defke", then the output will be 6, as we can turn s into "vtabcdefke" and "abcdef" is the longest consecutively increasing substring, and this is also starting with "a".To solve this, we will follow these steps −maxlen := 0length := 0qmarks := 0for each c ... Read More

350 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 is [3, 6, 7, 5, 4] this contains all consecutive elements from 3 to 7.To solve this, we will follow these steps −ret := 0for i in range 0 to size of nums - 1, dolhs := nums[i]rhs := nums[i]for j in range i to size of nums - 1, ... Read More

730 Views
Suppose we have a non-negative value n, we have to find the length of the longest consecutive run of 1s in its binary representation.So, if the input is like n = 1469, then the output will be 4, because binary representation of 156 is "10110111101", so there are four consecutive 1sTo solve this, we will follow these steps −count := 0while n is not same as 0, don := n AND (n after shifting one bit to the left)count := count + 1return countExampleLet us see the following implementation to get better understanding −def solve(n): count = 0 while n != 0: n = n & (n

217 Views
Suppose we have a list of numbers nums and another value diff, we have to find the length of the longest arithmetic subsequence where the difference between any consecutive numbers in the subsequence is same as diff.So, if the input is like nums = [-1, 1, 4, 7, 2, 10] diff = 3, then the output will be 4, because, we can pick the subsequence like [1, 4, 7, 10].To solve this, we will follow these steps −seen := an empty dictionary, default value is 0 when key is not presentmx := 0for each x in nums, doif x - ... Read More

657 Views
Suppose we have a binary string s. We are allowed to flip at most one "0" to "1", we have to find the length of the longest contiguous substring of 1s.So, if the input is like s = "1010110001", then the output will be 4, as if we flip the zero present at index 3, then we get the string "1011110001", here length of the longest substring of 1s is 4.To solve this, we will follow these steps −n := size of sans := 0, ones := 0, left := 0, right := 0while right < n, doif s[right] is ... Read More

127 Views
Suppose we have a list of numbers called logs and another value limit. Each element in logs[i] represents the size of logs generated by the i-th user. And limit represents the total size of logs we can store in our database. We have to find the largest x such that if we truncate every log in logs to be at most size x, and the sum of the left log sizes is at most limit. If no log needs to be truncated, then simply return the largest log size.So, if the input is like logs = [500, 200, 10000, 500, ... Read More

190 Views
Suppose we have a list of numbers nums, we want to split the list into two parts part1 and part2 such that every element in part1 is less than or equal to every element in part1. We have to find the smallest length of part1 that is possible (not 0 length).So, if the input is like nums = [3, 1, 2, 5, 4], then the output will be 3, because we can split the list like part1 = [3, 1, 2] and part2 = [5, 4].To solve this, we will follow these steps −p := minimum of numss := 0for ... Read More

423 Views
To extract the Number of days for each element from TimeDeltaIndex object, use the TimedeltaIndex.days 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 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 days from each element of TimeDeltaIndex −print("The number of days from the TimeDeltaIndex object...", tdIndex.days)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the ... Read More