Insert Interval

Description https://oj.leetcode.com/problems/insert-interval/ Difficulty: 2 Stars Analysis All intervals can be divided as intervals not overlapped with newInterval on the left (interval[i].end < newInterval.start) on the right (interval[i].start > newInterval.end) intervals overlapped with newInterval And all overlapping intervals appear consecutively in...

Implement strStr()

Description https://oj.leetcode.com/problems/implement-strstr/ Difficulty: ? Analysis Solved by KMP algorithm in time. Solution 1 class Solution { 2 public: 3 char *strStr(char *str1, char *str2) { 4 int len1 = strlen(str1); 5 int len2 = strlen(str2); 6 if (len2 > len1)...

Notes on Reservation Price as a Range An Incentive Compatible Measurement Approach

Introduction Reservation Price: maximum price a consumer is willing to pay for one unit of a good or service. There is growing interest in RP out of three factors advent of e-commerce has paved the way for mass customization and...

Best Time to Buy and Sell Stock I, II and III

Description I: https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/ The first problem requires that we compute the possible maximum profit for at most one transaction. II: https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ The first problem requires that we compute the possible maximum profit for at any number of transactions. III: https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/...

Scramble String

Description Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = “great”: great / \ gr eat / \ / \ g...