⚠️Note: This is not a mere dichotomy. Get an injection

Preface This article focuses on the simplest dichotomy, focusing on those issues that we have not paid attention to, and unravels the non-simple side of dichotomy. In this article, the author will take you to recognize dichotomy again. Introduction There are a number of n coins, and a scale. It is known that there is a counterfei ...

Posted on Wed, 22 Sep 2021 14:28:02 -0400 by sqishy

[algorithm LeetCode] 155. Minimum stack (stack; array)

155. Minimum stack force buckle (LeetCode) Released: 17:29:18, September 22, 2021 Problem description and examples Design a stack that supports push, pop and top operations and can retrieve the smallest element in a constant time. push(x) -- pushes element x onto the stack. pop() -- delete the element at the top of the stack. top() -- get ...

Posted on Wed, 22 Sep 2021 12:56:04 -0400 by cola

⭐ Introduction to algorithm ⭐ Stack and queue simple 02 -- LeetCode 225. Implement stack with queue

1, Title 1. Title Description     please use only two queues to implement a last in first out (LIFO) stack, and support all four operations of ordinary stack (push, top, pop and empty). Implement MyStack class:    void push(int x): push element x into the top of the stack.    int pop(): removes and retur ...

Posted on Wed, 22 Sep 2021 09:29:37 -0400 by jariizumi

Algorithm brushing -- bit operation

Code 1 : Power of Two Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x. Example 1 Input: n = 1 Output: true Explanation: 2^0 = 1 Example 2 Input: n = 16 Output: true Explanation: 2^4 = 16 Example 3 Input: n = 3 Output: false ...

Posted on Tue, 21 Sep 2021 04:06:05 -0400 by Stingus

LeetCode - Roman numeral to integer E[13]

Problem Description:   Roman numerals contain the following seven characters: I, V, X, L, C, D and M. Character value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, the Roman numeral 2 is written as II, which is two parallel ones. 12 is written as XI ...

Posted on Tue, 21 Sep 2021 03:28:07 -0400 by leap500

LeetCode kickback week 259

Weekly portal I came to work in the company. I had a week's competition in my spare time. I asked three questions. I'm very satisfied. Ha ha ha. 2011. Variable value after operation Time complexity: O ( n ) ...

Posted on Mon, 20 Sep 2021 15:46:55 -0400 by devang23

Week 16 algorithmic thinking - greed

Algorithmic thinking - greed The biggest difficulty in solving problems with greed is to prove that the choice of greed is the best. Commonly used proof methods: counter evidence method and mathematical induction method Number of non overlapping intervals 435. Non-overlapping Intervals(Medium) Throw darts to pierce the balloon 452. Minimum N ...

Posted on Mon, 20 Sep 2021 12:56:26 -0400 by djremiasz

[out of order version ● sword finger offer] daily algorithm problem punch in problem solution - double pointer (item No. 21,57,58)

Punch in day9 Question 1: Sword finger Offer 21. Adjust the array order so that odd numbers precede even numbers Enter an integer array and implement a function to adjust the order of numbers in the array so that all odd numbers are in the first half of the array and all even numbers are in the second half of the array. Example: Input ...

Posted on Mon, 20 Sep 2021 05:46:23 -0400 by venradio

LeetCode 975. Parity hop -- set+map + dynamic programming

Parity jump Given an integer array A, you can jump A certain number of times from A starting index. In the process of your jump, the 1st, 3rd, 5th... Jumps are called odd jumps, while the 2nd, 4th, 6th... Jumps are called even jumps. You can jump back from index i to index j (where i < j) as follows: When performing odd jumps (e.g., 1st, ...

Posted on Sun, 19 Sep 2021 18:39:42 -0400 by 3rve

Backtracking algorithm -- N queen problem

Backtracking algorithm -- N queen problem Backtracking algorithm has been bothering me for a long time. After watching the video of backtracking algorithm, I specially wrote this algorithm to deepen my impression. General formula of backtracking algorithm The backtracking algorithm has a general formula. void backtrack(){ if(Judge whe ...

Posted on Sun, 19 Sep 2021 13:16:23 -0400 by NTM