• leetcode410. Split Array Largest Sum


    Subject requirements Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays. Note: If n is the length of array, assume the following constraints are satisfied: 1 ≤ n ≤ 1000 […]

  • Solution to leetcode PHP — D65 892. Surface area of 3D shapes


    D65 892. Surface Area of 3D Shapes Title Link 892. Surface Area of 3D Shapes Title Analysis Given a three-dimensional array, returns the surface area of the stroke cylinder. thinking In a 3D array,$arr[$i][$j]The value of represents the height of the cylinder at that point. Therefore, for each value, 6 copies (1 * 1 * […]

  • 【LeetCode Easy】021 Merge Two Sorted Lists


    Easy 021 Merge Two Sorted Lists Description: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Input: 1->2->4, 1->3->4Output: 1->1->2->3->4->4 My Solution: In order to reduce the space complexity, the final result is directly modified on LIST1 […]

  • leetcode441. Arranging Coins


    Subject requirements You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can be formed. n is a non-negative integer and fits within the range of a 32-bit signed […]

  • Leetcode PHP solution — D66 896. Monotonic array


    D66 896. Monotonic Array Title Link 896. Monotonic Array Title Analysis Given an array of numbers, determine whether to monotonically increase or decrease. Monotonically increasing means that for the nth digit, the array after it is greater than or equal to it.Monotonic decrement means that the array after it is smaller than it. thinking First, […]

  • [leetcode] 128. Longest continuous sequence


    subject Given an array of unsorted integers, find the length of the longest consecutive sequence. The time complexity of the algorithm is required to beO(n)。 Example: Input: [100, 4, 200, 1, 3, 2] Output: 4 Explanation: the longest continuous sequence is [1, 2, 3, 4]. Its length is 4. Title Solution At the beginning of […]

  • 929 unique email address


    Preface The first unique email address of weekly contest 108: Each email consists of a local name and a domain name [email protected] separation. For example, [email protected],aliceIs the local name, andleetcode.comIt’s a domain name. In addition to lowercase letters, these emails may also contain’,’or’+’。 If theLocal nameAdd a period between some characters in the section(’.’), the […]

  • [LeetCode]15. 3Sum


    Given an array nums of n integers, are there elements a, b, c in numssuch that a + b + c = 0? Find all unique triplets in the array whichgives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums = [-1, 0, 1, 2, -1, -4], […]

  • leetcode450. Delete Node in a BST


    Subject requirements Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion can be divided into two stages: Search for a node to remove. If the node is found, delete the […]

  • Leetcode PHP solution — D67 485. Max conservative ones


    D67 485. Max Consecutive Ones Title Link 485. Max Consecutive Ones Title Analysis Given a binary array (an array containing only 0 and 1), the longest 1 string is returned. thinking Traverse one by one, and count if it is 1. If 0 is encountered, judge whether the current count is greater than the maximum […]

  • [Leetcode]16. 3Sum Closest


    Given an array nums of n integers and an integer target, find threeintegers in nums such that the sum is closest to target. Return thesum of the three integers. You may assume that each input would haveexactly one solution. Example: Given array nums = [-1, 2, 1, -4], and target = 1. The sum that […]

  • Leetcode PHP solution — d68 283. Move zeroes


    D68 283. Move Zeroes Title Link 283. Move Zeroes Title Analysis Given an array of integers, move elements with a value of 0 to the end of the array without changing the order in which other elements appear. thinking Calculate how many elements there are in total. Then fill 0 to the calculated array length […]