1, Bit operation
● ^ can be understood as non carry addition ● a^a=0 ● a^0=a
Topic 1
In a group of numbers, only one number appears odd, and the other numbers appear even. Find the number whose occurrence is odd.
public static void printOddTimesNum1(int[] arr) {
int eor = 0;
for (int i : arr) {
eor ^= i;
}
System.out ...
Posted by always_confused on Sat, 23 Apr 2022 05:36:21 +0300
Leetcode writing diary 2021.2.6 (supplementary)
Title Link: https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/solution/mian-shi-ti-09-yong-liang-ge-zhan-shi-xian-dui-l-3/
Problem Description: Queue with two stacks
Answer 1: Using Stack
code:
import java.util.Stack;
class CQueue {
Stack<Integer> appendSt ...
Posted by DaveMate on Thu, 21 Apr 2022 04:07:23 +0300
Solution to the 227th weekly game of LeetCode
Check whether the array is sorted and rotated
Original question link
https://leetcode-cn.com/problems/check-if-array-is-sorted-and-rotated/
Problem solving ideas
Just test directly, because the data range of the array is very small
O
( ...
Posted by christo16 on Wed, 20 Apr 2022 22:46:38 +0300
preface
For the supplement of the following code, see the following link: Binary tree theory and code in code Capriccio
This paper mainly studies according to the learning route of the link, reading its ideas and self cognition, and adding code comments Convenient for self-study, interested students can also collect and pay attention
The ...
Posted by XPertMailer on Wed, 20 Apr 2022 08:16:34 +0300
1. Introduction to single linked list and memory layout
The linked list is an ordered list, but it is stored in memory as follows: Summary: 1) Linked list is stored in the form of nodes, which is chain storage 2) Each node contains data field and next field: point to the next node 3) As shown in the figure: it is found that each node of t ...
Posted by cooler75 on Tue, 19 Apr 2022 13:06:47 +0300
catalogue
1, Title Description
English description
Chinese description
Examples and descriptions
2, Problem solving ideas
3, AC code
Java (2D dp)
4, Problem solving process
First fight
Second stroke
1, Title Description
English description
Given an m x n binary matrix filled with 0's and 1's, find the largest square contai ...
Posted by MarkR on Tue, 19 Apr 2022 08:33:52 +0300
5676. Minimum operands for generating alternating binary strings (question 1)
subject
Give you a string s consisting only of the characters' 0 'and' 1 '. In one step, you can change any '0' to '1', or '1' to '0'.
Alternating string is defined as: if two adjacent characters are not equal in the string, the string is an alternating string. ...
Posted by farsighted on Tue, 19 Apr 2022 01:43:33 +0300
Implement the StreamChecker class as follows:
StreamChecker(words): Constructor, init the data structure with the given words.
query(letter): returns true if and only if for some k >= 1, the last k characters queried (in order from oldest to newest, including this letter just queried) spell one of the words in the given list.
Example:
Str ...
Posted by Chinese on Mon, 18 Apr 2022 19:56:52 +0300
subject
Portal
In MATLAB, there is a very useful function reshape, which can reshape a matrix into another new matrix of different sizes, but retain its original data. A matrix represented by a two-dimensional array and two positive integers r and c are given to represent the number of rows and columns of the matrix to be reconstructed res ...
Posted by dipenmistry on Mon, 18 Apr 2022 15:25:30 +0300
General points:
Clarify the meaning of dp. During initialization, pay attention to limiting the input. After initialization, pay attention to the iteration after initialization! Start after initialization! Start after initialization!
Step: define the meaning and recurrence formula, and create dp; Initialize dp; Iteration dp
Difference between ...
Posted by Drewser33 on Mon, 18 Apr 2022 07:39:28 +0300