Design Movie Rental System Solution

Design Movie Rental System Solution You have a movie renting company consisting of n shops. You want to implement a renting system that supports searching for, booking, and returning movies. The system should also support generating a report of the currently rented movies. Each movie is given as a 2D integer array entries where entries[i] = [shopi, moviei, pricei] indicates that … Read more

Remove All Occurrences of a Substring Solution

Remove All Occurrences of a Substring Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed: Find the leftmost occurrence of the substring part and remove it from s. Return s after removing all occurrences of part. A substring is a contiguous sequence of characters in a string. Example 1: Input: s = “daabcbaabcbc”, part = “abc”Output: “dab”Explanation: The following operations are done: Example 2: … Read more

Remove One Element to Make the Array Strictly Increasing

Remove One Element to Make the Array Strictly Increasing Solution Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true. The array nums is strictly increasing if nums[i – 1] < nums[i] for each index (1 <= i < nums.length). Example 1: Input: nums = [1,2,10,5,7]Output: trueExplanation: By removing 10 at index … Read more

Add to Array-Form of Integer Leetcode

Add to Array-Form of Integer Solution For a non-negative integer X, the array-form of X is an array of its digits in left to right order.  For example, if X = 1231, then the array form is [1,2,3,1]. Given the array-form A of a non-negative integer X, return the array-form of the integer X+K. Example 1: Input: A = [1,2,0,0], K = 34Output: [1,2,3,4]Explanation: 1200 + … Read more

1-bit and 2-bit Characters Solution Leetcode

1-bit and 2-bit Characters Solution We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). Now given a string represented by several bits. Return whether the last character must be a one-bit character or not. The given string will always end … Read more