Building Text Editor From Scratch in C - Part I
Building a text editor from scratch in C What I learned so far I learned that I need to start with a simple read() operation that reads user input. while (read(STDIN_FILENO, &c, 1) == 1); But there was a caveat: if you use the read() operation, the terminal starts in canonical mode. This mode sends keyboard input only after the user presses Enter, so it was not very useful because I want to process all keypresses. ...
LeetCode - 150 - Target Sum
The problem You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers. For example, if nums = [2, 1], you can add a '+' before 2 and a '-' before 1 and concatenate them to build the expression "+2-1". Return the number of different expressions that you can build that evaluate to target. ...
LeetCode - 150 - Coin Change II
The problem You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return 0. You may assume that you have an infinite number of each kind of coin. The answer is guaranteed to fit into a signed 32-bit integer. ...
LeetCode - 150 - Best Time to Buy and Sell Stock with Cooldown
The problem You are given an array prices where prices[i] is the price of a given stock on the i-th day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: After you sell your stock, you cannot buy stock on the next day (i.e., cooldown one day). Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again). ...
LeetCode - 150 - Partition Equal Subset Sum
The problem Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal, or false otherwise. Examples Input: nums = [1,5,11,5] Output: true Explanation: The array can be partitioned as [1, 5, 5] and [11]. Input: nums = [1,2,3,5] Output: false Explanation: The array cannot be partitioned into equal sum subsets. Constraints 1 <= nums.length <= 200 1 <= nums[i] <= 100 Explanation From the description of the problem, we learn that we are given a non-empty array nums that contains only positive integers, and we want to find out if we can partition the array into two different subsets such that the sum of each subset is equal. ...