Moment For Technology

LeetCode-136- A number that appears only once

Given an array of non-empty integers, each element occurs twice except for one. Find the element that appears only once. Description: Your algorithm should have linear time complexity. Can you do this without using extra space? See the LeetCode website for an example. The copyright belongs to Lankou Network. Commercial reprint please contact the official authorization, non-commercial reprint...

LEETCODE -121- The best time to buy or sell stocks

Given an array of prices, the ith element of prices[I] represents the price of a given stock on day I. You can only buy the stock on a certain day and sell it on a different date in the future. Design an algorithm to calculate the maximum profit you can make. Return the maximum profit you can make from the transaction. If you can't make any profit, return 0. For an example, see Leetcode...

Leetcode-125 - Verify palindrome strings

Given a string, verify that it is a palindrome string. Only consider alphanumeric characters. You can ignore the case of the letters. Note: In this case, we define an empty string as a valid palindrome string. See the LeetCode website for an example. The copyright belongs to Lankou Network. Commercial reprint please contact the official authorization, non-commercial reprint please indicate the source.

Leetcode-067 - Binary Sum

Description: Give you two binary strings and return their sum (in binary). The input is a non-empty string and contains only the digits 1 and 0. See the LeetCode website for an example. The copyright belongs to Lankou Network. Commercial reprint please contact the official authorization, non-commercial reprint please indicate the source.

Question 21: The diameter of the binary tree

Diameter points of a binary tree: what the root node needs to do is to add the height of the left subtree and the right subtree, and then add 1 to get the diameter length of the node. An intermediate variable Max is used to record the longest diameter, and the final Max is the result. Calculate the diameter: 1. Get the height of the left subtree 2. Get the height of the right subtree 3. Add 1.

LeetCode-118- Yang Hui Triangle

NumRows = NumRows = NumRows = NumRows = NumRows = NumRows = NumRows = NumRows = NumRows In the Yang Hui Triangle, each number is the sum of the numbers at the upper left and the upper right of it. See the LeetCode website for an example. The copyright belongs to Lankou Network. Commercial reprint please contact the official authorization, non-commercial reprint please indicate the source.

LeetCode-119- Yang Hui Triangle II

Description: Given a non-negative index k, where k ≤ 33, return the KTH row of the Yanghui Triangle. In the Yang Hui Triangle, each number is the sum of the numbers at the upper left and the upper right of it. See the LeetCode website for an example. The copyright belongs to Lankou Network. Commercial reprint please contact the official authorization, non-commercial reprint please indicate the source.

Question 20: The diameter of the binary tree

Important: The diameter of a binary tree is the maximum number of nodes formed by the left and right subtrees and the root node minus one. Set an intermediate variable Max, and compare the number of nodes formed by left and right subtrees and root nodes with Max each time. Save the larger node with Max until the longest node path formed by all left and right subtrees and root nodes is Max, and the maximum diameter is Max with max-1 finally. And the essence of this problem is to find the depth of the tree.

Leetcode-083 - Removes duplicate elements in sorted linked list

Description: There is a linked list in ascending order. Given the head node of the linked list, please delete all duplicate elements so that each element appears only once. Returns the resulting list, also in ascending order. See the LeetCode website for an example. The copyright belongs to Lankou Network. Commercial reprint please contact the official authorization, non-commercial reprint please indicate the source.

Search
About
mo4tech.com (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.