## Find the median of two positively ordered arrays - LeetCode

4. Find the median of two positive arrays Title Link O(m + n) algorithm class Solution { public double findMedianSortedArrays(int[] nums1, int[] nums2) { int n = nums1.length + nums2.length; int mid1 = (n + 1) / 2; int mid2 = (n + 2) / 2; int p1 = 0, p2 = 0, num1 = 0, num2 = 0; for(int i = 1; i < ...

Posted by yjanni on Thu, 28 Apr 2022 04:50:49 +0300

## java data structure and algorithm -- LeetCode4: find the median of two positively ordered arrays

java data structure and algorithm question brushing directory (Sword finger Offer, LeetCode, ACM) --- main directory ------ continuous update (if I can't get in, it means I haven't finished writing): https://blog.csdn.net/grd_java/article/details/123063846 Train of thought analysis Double pointer traversal method, first get the subs ...

Posted by melissal on Wed, 27 Apr 2022 11:41:31 +0300

## LeetCode 1579 ensures that the graph can fully traverse the LeetCode path of HERODING

Alice and Bob share an undirected graph with n nodes and 3 types of edges: Type 1: can only be used by Alice traverse. Type 2: can only be Bob traverse. Type 3: Alice and Bob can be traversed. You are given an array edges , where edges[i] = [typei, ui, vi] means that there is a bidirectional edge of type typei between nodes ui and vi . Pleas ...

Posted by Tokunbo on Wed, 27 Apr 2022 02:30:06 +0300

## [Leetcode]928. Minimize Malware Spread II

Title address: https://leetcode.com/problems/minimize-malware-spread-ii/ Given a n n An undirected graph with n nodes is given by adjacency matrix. Each node represents a node in a network. Give another array A ...

Posted by msarefin on Tue, 26 Apr 2022 09:58:44 +0300

## Summary of common data structures and algorithms (including examples and complete codes)

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 question brushing diary 2021.2.6 (supplementary)

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

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

## [code Capriccio] column of binary tree and binary search tree (java version with comments)

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

## Single linked list algorithm design (including large factory interview questions)

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

## LeetCode_ Array_ 221. Maximum square [dynamic programming, simulation] [Java] [medium]

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