Leetcode.1005. Maximized array sum after K negations - greedy + count sorting

12.6 one question per day - maximum array sum after K inversions Enter an array of integers and an integer k to modify the array as follows 1. Select a subscript i and replace num [i] with - num [i] 2. Repeat this process exactly k times. You can select the same subscript i multiple times. When the array is modified in this way, the maximum po ...

Posted by nicholasstephan on Mon, 06 Dec 2021 13:03:44 -0800

Algorithm notes - Basic Algorithms

Quick sort Algorithm idea: select a number in the array x x x. Make all > = x >=x >=The number of X is on the right, ...

Posted by yellowzm on Mon, 06 Dec 2021 11:37:59 -0800

AC automaton based on double array trie tree (with explanation of JAVA code)

AC Automation Based on Double Array trie Tree We've already covered that before AC Automation However, in practice, if the dictionary tree that needs to be built is very large, the original version of AC automaton will take more time to query, and based on Double array trie tree AC automata can just make up for this. Below we will impleme ...

Posted by zoobooboozoo on Mon, 06 Dec 2021 10:18:18 -0800

Common oj problems of stack and queue (bracket matching problem, stack implementation queue, queue implementation stack, design loop queue)

1, Bracket matching problem 1. Title Requirements:     2. General idea After traversing the string, if it is an open parenthesis, let it enter the stack. If it is a right parenthesis, let it match the top element of the stack (provided that there are elements in the stack). If the matching is successful, let the top element out of th ...

Posted by aquayle on Sun, 05 Dec 2021 13:43:55 -0800

[data structure] binary tree (C language)

  This paper briefly introduces the concept of tree. The more important are the implementation of heap, heap sorting, TOP-K problem, traversal of binary tree (pre, middle, post order and sequence traversal) and the implementation of binary tree function catalogue 1, Concept and structure of tree 1.1 concept of tree 1.2 representation o ...

Posted by mantona on Sun, 05 Dec 2021 12:59:40 -0800

Data structure Java data structure stack and queue and LeetCode related interview questions

1. Stack 1.1 concept Stack: a special linear table that allows insertion and deletion of elements only at a fixed end. One end for data insertion and deletion is called the top of the stack, and the other end is called the bottom of the stack. The data elements in the stack follow the principle of Last In First Out LIFO (Last In First Out ...

Posted by Mohammad on Sun, 05 Dec 2021 11:30:29 -0800

Java data structure Day11 -- stack implementation inverse Polish expression (suffix expression) calculator

Today, I happened to talk with some students. Let's share itSimpleDateFormat has thread safety problems. After Java 8, thread safe LocalDate, LocalTime, or LocalDateTime can be used, but to be honest, this LocalDate is much more troublesome than SimpleDateFormat.. but you can write a tool class to encapsulate common methods. So it doesn't seem ...

Posted by NTGr on Sun, 05 Dec 2021 09:10:20 -0800

9, Notes on data structure of postgraduate entrance examination -- traversal of binary tree and construction of clue binary tree, common error prone points

1, Traversal of binary tree Access each node in the tree according to a search path, so that each node is accessed. It is mainly divided into first order traversal, middle order traversal, second order traversal and sequence traversal 2, Preorder traversal 2.1 manual calculation The exam usually gives the shape of a tree and writes its preo ...

Posted by MHz on Sun, 05 Dec 2021 08:04:55 -0800

L2 - Fundamentals of data structures - Lesson 07 - Dynamic Arrays

L2 - Fundamentals of data structures - Lesson 07 - Dynamic Arrays Original gourd teacher Yunfan youpei 2020-12-19 13:34 L2 - Fundamentals of data structures - Lesson 07 - Dynamic Arrays Variable length array cin >> n; int a[n]; Strictly speaking, the above code is not supported by c + + standard, although most compilers can compile it ...

Posted by ab4net on Sun, 05 Dec 2021 07:16:12 -0800

The concept and terminology of tree

concept Tree is an abstract data type or a data structure that implements this abstract data type, which is used to simulate a data set with the nature of tree structure. It is a set with hierarchical relationship composed of n (n > = 1) finite nodes. It is called "tree" because it looks like an upside down tree, that is, it has ro ...

Posted by Geof on Sun, 05 Dec 2021 02:12:21 -0800