The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but 'epoch' is often used as a synonym for Unix time. Some systems store epoch dates as a… Continue reading Epoch Time
Tag: Miscellaneous
December Problem Solving
1 December - Minimum number of jumps to reach end | Set 2 (O(n) solution). SO 2 December - find sum(S) of all contiguous sub-array's max difference, SO 3 December - The Enlightened Ones. HE 4 December - Minimize Cash Flow among a given set of friends who have borrowed money from each other. GFG… Continue reading December Problem Solving
OOPS Basic
The four principles of OOP. 1. Encapsulation 2. Abstraction 3. Inheritance 4. Polymorphism Inheritance is a mechanism of acquiring the features and behaviors of a class by another class. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. Inheritance implements… Continue reading OOPS Basic
DS Discussion
Why Quick Sort preferred for Arrays and Merge Sort for Linked Lists?
Reservoir sampling
Proof 1 , Explanation Simple explanation on quora
Generating Random Numbers without Modulo Bias
http://stackoverflow.com/questions/10984974/why-do-people-say-there-is-modulo-bias-when-using-a-random-number-generator https://zuttobenkyou.wordpress.com/2012/10/18/generating-random-numbers-without-modulo-bias/ The random numbers generated using modulo are biased. Check the above article. The correct way of implementation is also specified above.
Shuffle an array
The general method for shuffling is biased. Check this - https://spin.atomicobject.com/2014/08/11/fisher-yates-shuffle-randomization-algorithm/ and http://www.i-programmer.info/programming/theory/2744-how-not-to-shuffle-the-kunth-fisher-yates-algorithm.html When shuffling the maximum number of possible outcome can't be more then n!( n is the number of items being shuffled). So if the algo generate more then n! possible outcome then the algo is biased. The Knuth Fisher-Yates Algorithm produces unbiased shuffled outcome. It… Continue reading Shuffle an array
Important Questions | Mixed | 1
Check if two rectangles overlap - instead of checking if they overlap we check if a rectangle lies outside. So we check if a rectangle lies on the right,left, top or bottom of the first rectangle. If it lies outside then don't overlap. Else they overlap. SO Amazon: Count Negative Integers in Matrix - Numbers… Continue reading Important Questions | Mixed | 1
Random Problem Set – 1
Maximum Number of glasses required at a party Find Excel column name from a given column number. Given n positive real numbers, find whether there exists a triplet among this set such that, the sum of the triplet is in the range (1, 2). Do it in linear time and O (1) space. The approach is important… Continue reading Random Problem Set – 1
Problems Set For Later Consideration
Repeated Element from an Array (Randomized Algorithm) - in an array of n elements n/2 elements are distinct and n/2 elements are same. We need to find the element that has been repeated. Read this ans as well. Third largest element in an array of distinct elements Print shortest path to print a string on screen… Continue reading Problems Set For Later Consideration
You must be logged in to post a comment.