Algorithm and data structure exercises
The optimal solution to the Java IT famous enterprise algorithm and data structure problem
1. Stack and queue
- Design a stack with getMin function
- A queue of two stacks
- How to refer to a recursive function and stack operation inverse order
- Cat and dog queue
- Use one stack to implement sorting of another stack
- To solve the problem of Hannover Tower, first modify the game rules: the line limit cannot be moved directly from the leftmost to the rightmost or from the rightmost to the leftmost, but must pass through the middle. Find the optimal movement process and total number of steps when the tower is N layers again.
- Generate a window maximum array
- MaxTree for constructing data
- Given a shaping matrix map, the values are 0 and 1, find the maximum rectangular area of 1 among all matrix regions where all 1 is the number of 1.
- The maximum value minus the number of sub-arrays with a minimum value less than or equal to num
2. Link list issues
- Given the header pointers head1 and head2 of two ordered linked lists, print the common part of the two linked lists
- Delete the k-th until the node in single and double-linked lists
- Delete the nodes in the middle of the linked list and the nodes at a/b
- Implement functions that invert one-way linked lists and invert two-way linked lists respectively
- Reverse part of one-way linked list
- Arthur's Problem with the Round Single Link List
- Determine whether a linked list is palindromic structure
- Divide the one-way linked list into small left, equal middle, large right
- Copy a linked list containing random pointer nodes
- Two single linked lists generate an added link list
- A series of problems of intersecting two linked lists
- Reverse order between each k nodes of a single linked list
- Delete nodes with repeated values in unordered single linked lists
- Delete a specified value node in a single linked list
- Convert search binary tree to bidirectional link table
- Selection sorting of single linked lists
- A weird way to delete nodes
- Insert new nodes into an ordered circular single-linked list
- Merge two ordered single-linked tables
- Reorganize the single-linked table in the left and right half area
Binary Tree Problem
- Recursive and non-recursive methods to realize the preorder, middle order and postorder traversal of binary trees respectively
- Print the boundary node of the binary tree
- How to print a binary tree more intuitively
- Binary tree serialization and deserialization
- God-level method to traverse binary trees
- Find the longest path length of the accumulated sum for the specified value in the binary tree
- Find the largest search binary tree in binary tree
- Find the maximum topology in the binary tree that meets the search binary tree criteria
- Binary tree by layer printing and ZigZag printing
- Adjust search for two wrong nodes in the binary tree
- Determine whether the t1 tree contains all the topological structures of the t2 tree
- Determine whether there are subtrees in the t1 tree that have exactly the same topology as the t2 tree
- Determine whether a binary tree is a balanced binary tree
- Rebuild the search binary tree based on the post-order array
- Determine whether a binary tree is a search binary tree and a complete binary tree
- Generate balanced search binary trees through ordered arrays
- Find the successor node of a node in the binary tree
- Find the nearest common ancestor of two nodes in the binary tree
- Tarjan algorithm and concurrent search set solve the problem of batch query of recent public ancestors between binary tree nodes
- Maximum distance between binary tree nodes
- Reconstructing binary trees in combination with preorder, middle order and postorder arrays
- Generate post-order arrays through preorder and in-order arrays
- Statistics and generates all different binary trees
- Count the number of nodes in a completely binary tree
- Maximum incremental subsequence
Recursive and dynamic programming
- Recursive and dynamic programming of Fibonacci series problems
- The minimum path to the matrix
- Minimum amount of currency to exchange for money
- How to exchange money
- The Tower of Hannover
- The longest common subsequence problem
- The longest public string problem
- Minimum editing cost
- Interleaved composition of strings
- Dungeons and Dragons game issues
- Number of numbers converted to letter combinations
- The number of compositions of the expression to obtain the desired result
- Card game problem in a line
- Jump game
- The longest continuous sequence in an array
- N Queen's Problem
String problem
- Determine whether two strings are guarding the deformation word
- Sum of substrings of numbers in strings
- Remove the k substrings that appear in the string in succession
- Determine whether two strings are rotating words
- Convert an integer string to an integer value
- Replace specified strings that appear continuously in strings
- Statistical strings for strings
- Determine whether all characters in the character array have only appeared once
- Find strings in an ordered but empty array
- Adjustment and replacement of strings
- Flip string
- Minimum distance between two strings in an array
- Add a minimum of characters to make the string as a palindromic string
- According to the validity of the string and the maximum effective length
- Formula string evaluation
- There must be a number of binary strings on the left of 0
- Stitching all strings to produce capital strings with the smallest dictionary order
- Find the longest non-repetitive substring of the string
- Find the new type of character mentioned
- Minimum length containing substring
- Minimum number of palindrome segmentation
- String matching problem
- Implementation of Dictionary Tree (Prefix Tree)
Bit operation
- No additional variables are used to exchange two numbers
- Find the larger number of two numbers without any comparison
- Only bit operations are used without arithmetic operations to implement addition, subtraction, multiplication and division of integers
- How many 1cccs are there in the binary expression of integers
- Find odd numbers in an array where other numbers appear evenly
- Find a number that only appears once in an array where other numbers appear k times
Array and matrix problems
- Circle printing matrix
- Turn the square matrix clockwise by 90°
- "一" glyph printing matrix
- Find the smallest number of k in an unordered array
- The shortest subarray length to sort
- Find the number of occurrences greater than N/K in the array
- Find numbers in a matrix where rows and columns are sorted
- The longest integable sub-array is obtained
- No repeated printing of sorted arrays adds all quads and triplets for a given value
- The accumulated sum of the longest subarray length in an array of unsorted positive numbers is the given value
- Problem on the longest subarray series of accumulated sums in an unsorted array
- The accumulated sum of the longest subarray length in an unsorted array is less than or equal to the given value
- Natural number array sorting
- Odd subscripts are all odd numbers or even subscripts are all even numbers
- Subarray accumulation and maximum
- Maximum accumulation sum problem of submatrix
- Find a local smallest location in the array
- The maximum cumulative product of sub-arrays in an array
- Print the largest top K of N arrays
- The boundaries are all 1 maximum square size
- This location is not included to the array worth cumulative multiplication
- Array partition adjustment
- Find the shortest path value
- The smallest positive integer that does not appear in the array
- The maximum difference between adjacent numbers after array sorting is 9
practise
- Replace spaces (sword pointing to offer)
- Search in a two-dimensional array (sword pointing to offer)
- Reversal link list (sword to offer)
- Delete the repeated nodes of the linked list (sword to offer)
- The minimum number of the rotation array (sword pointing to the offer)
- Repeated numbers in array (sword to offer)
- String of number worth (sword pointing to offer)