All Posts

Leetcode 1646: Get Maximum in Generated Array

Given an integer n, an array nums of length n+1 is generated with the following rules:

  • nums[0] = 0
  • nums[1] = 1
  • nums[2 * i] = nums[i] when 2 <= 2 * i <= n
  • nums[2 * i + 1] = nums[i] + nums[i + 1] when 2 <= 2 * i + 1 <= n

Return the maximum value in the array nums.

Leetcode 1652: Defuse the Bomb

You are given a circular array ‘code’ and an integer ‘k’. To decrypt the code, you must replace every element in the array based on the value of k. If k > 0, replace the i-th element with the sum of the next k elements. If k < 0, replace the i-th element with the sum of the previous k elements. If k == 0, replace the i-th element with 0. The array is circular, meaning the next element of the last one is the first, and the previous element of the first one is the last.

Leetcode 1656: Design an Ordered Stream

You are given a stream of n (id, value) pairs, where id is an integer between 1 and n, and value is a string. The task is to design a stream that returns the values in increasing order of their id. After each insertion, the stream should return the largest possible chunk of values that appear next in the order.

Leetcode 1662: Check If Two String Arrays are Equivalent

You are given two string arrays word1 and word2. Return true if these two arrays represent the same string when their elements are concatenated in order, otherwise return false.

Leetcode 1668: Maximum Repeating Substring

You are given two strings: sequence and word. A string word is considered ‘k-repeating’ in sequence if word concatenated k times forms a substring of sequence. The task is to return the maximum value of k such that word repeated k times appears as a substring in sequence. If no such substring exists, return 0.

Leetcode 1672: Richest Customer Wealth

You are given a 2D list accounts, where each row represents a customer and each element within a row is the amount of money they have in a particular bank. Your task is to return the wealth of the richest customer. A customer’s wealth is the sum of all their bank accounts’ balances. The richest customer is the one with the maximum wealth.