[Swordfinger Offer] Search and Backtrace Algorithms

Today is still the application of search algorithm, but today there are more depth-first search algorithms, the data structure is still a tree, involves more knowledge of recursion, so the code volume is less. Swordfinger Offer 26.Substructure of Trees Enter two binary trees A and B to determine if B is a substructure of A. (A convention empt ...

Posted by hws on Wed, 15 Sep 2021 17:29:17 -0700

LeetCode 138 copies linked lists with random pointers

Title Description: Give you a linked list with a length of n. each node contains an additional random pointer random, which can point to any node or empty node in the linked list. To construct this linked list   Deep copy.   The deep copy should consist of exactly n new nodes, in which the value of each new node is set to the value ...

Posted by Zaid on Mon, 13 Sep 2021 21:05:07 -0700

[Java] summary of basic interview questions!

1. Why do you have to override the hashcode method when you override the equals method? equals() and hashCode() are both built-in methods in the Object class. The native equals() uses = = to compare the memory addresses of the two objects. hashCode is a native method. Different objects get different hashcodes. A subclass of Object, such as St ...

Posted by wisewood on Mon, 13 Sep 2021 14:20:26 -0700

Array topic two-part search

array Binary search 704. Two point search - LeetCode (LeetCode CN. Com) Solution: class Solution { public int search(int[] nums, int target) { int mid; int left = 0, right = nums.length-1; while (left <= right){ // mid = (left + right) / 2; mid = left + ((right-left) / 2);//Overflow can ...

Posted by djjamiegee on Sun, 12 Sep 2021 14:38:24 -0700

Force buckle leetcode top100 1. Sum of two numbers

Title: given an integer array nums   And an integer target value, please find and as the target value target in the array    That   Two   Integers and return their array subscripts. You can assume that each input will correspond to only one answer. However, the same element in the array cannot be repeated in the answer. ...

Posted by bdichiara on Fri, 10 Sep 2021 12:47:31 -0700

Leetcode: 68. Align text left and right

subject Source: LeetCode Link: https://leetcode-cn.com/problems/text-justification Given an array of words and a length maxWidth, rearrange the words into text with exactly maxWidth characters per line and aligned left and right ends. You should use "greedy algorithm" to place a given word; That is, put as many words in each line as ...

Posted by ozzythaman on Fri, 10 Sep 2021 01:02:00 -0700

The number i/ii/iii that appears only once in LeetCode

The number i that appears only once Title Description Topic analysis When I first looked at the question of xxxx, I had no idea at all. The method is too inefficient. Later, I saw on the Internet that the solution uses XOR, but I haven't understood what the principle is. Recently, the school is learning "the principle of computer ...

Posted by taiger on Sun, 05 Sep 2021 11:16:27 -0700

Summary of Array and Chain List Properties

1. Storage of data structures There are only two ways to store data structures: array (sequential storage) and chain table (chain storage). What do you mean by this sentence? Aren't there any data structures like hashes, stacks, queues, heaps, trees, graphs, etc? When we analyze problems, we must have recursive thinking, from top to bottom, ...

Posted by jonex on Thu, 02 Sep 2021 01:02:15 -0700

LeetCode 6-10 question explanation Java version (ten thousand words picture and text explanation LeetCode algorithm question 1-5 = = = = > > > < recommended Collection >)

Question 6. ZigZag Conversion 1. Topic description (medium difficulty) Is to give a string, and then arrange the characters in a vertical "z", which is what it looks like below. Then output each character in line, line 0, line 1, line 2 2. Solution I Follow the process of writing Z, traverse each character, and then sav ...

Posted by shan169 on Wed, 01 Sep 2021 15:06:27 -0700

LeetCode - operation of numbers

Integer division thinking Cross border problem Critical point negative 0x8000000, positive 07fffffConvert a and b to negative numbers, and the highest bit can be used.The problem becomes a loop, which is a < = BCritical point: a==0 return 0;if ((a == 0x80000000 && b == -1) || (a == 0x7fffffff && b ...

Posted by ict on Wed, 01 Sep 2021 11:00:25 -0700