Leetcode--Java--151. Flip the words in the string

Title Description Give you a string s and flip all the words in the string one by one. A word is a string of non whitespace characters. Use at least one space in s to separate words in the string. Please return a string that flips the word order in s and connects it with a single space. explain: The input string s can contain extra spaces befo ...

Added by stevieontario on Fri, 05 Nov 2021 22:34:04 +0200

[Coding] LeetCode record

Common data structures 1. Sets 2. Sorting 3.Binary -Template /** * Raw/Binary Search: In an ordered array, the existence of the search element target, the existence of a return index, and the absence of a Return-1 */ public static int binarySearch(int[] nums, int target) { int left = 0; int right = nums.length - 1; while ...

Added by mithras on Wed, 03 Nov 2021 18:22:39 +0200

LeetCode 230. The K-th smallest element in binary search tree / 476. Complement of numbers / 211. Add and search words - data structure design (dictionary tree)

230. The K-th smallest element in the binary search tree One question per day on October 17, 2021 Title Description Given the root node root of a binary search tree and an integer k, please design an algorithm to find the K smallest element (counting from 1). Example 1: Input: root = [3,1,4,null,2], k = 1 Output: 1 Example 2: I ...

Added by elite_prodigy on Tue, 02 Nov 2021 13:02:51 +0200

Initial knowledge and basic OJ exercises of stack and queue

  this article only uses two common implementation methods - dynamic array stack and chain queue. If you want to see more implementation methods of queue and stack, you can see the section on queue and stack in my following article: Figure 5 implementation of five interfaces,    the queue and stack implementations in this articl ...

Added by deezerd on Sun, 31 Oct 2021 21:37:21 +0200

leetcode 14 day question brushing plan - efficient interview preparation

summary The adjacency matrix is constructed from the given matrix List<List<Integer>> graph = new ArrayList<>(n); for (int i = 0; i < n; ++i) graph.add(new ArrayList<>(3)); for (int[] path : paths) { graph.get(path[0] - 1).add(path[1] - 1); graph.get(path[1] - 1).add(path[ ...

Added by mantona on Sun, 31 Oct 2021 16:45:36 +0200

leetcode 203. Remove linked list elements

1. Title Description: Here are the tips given in the original question: Here is the definition form of interface function and linked list given in the original question: /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* removeElements(struct L ...

Added by kansaschuck on Sat, 30 Oct 2021 07:32:20 +0300

[day ⑥ of hero learning algorithm] counting method -- with Leetcode problem solution (implemented in C language)

✨ preface ✨         In this series, bloggers are ready to share the algorithm of punching in and learning in the community of 10000 people and 1000 questions every day. Bloggers are also Xiaobai, so they can understand the confusion of novices when brushing questions, so pay attention to bloggers and learn an algorithm ev ...

Added by jobe1 on Wed, 27 Oct 2021 09:32:39 +0300

LeetCode(215) -- the kth largest element in the array (priority queue)

1, Priority queue priorityQueue is the implementation of the Queue interface, which can sort the elements and put them into basic packaging types or user-defined classes. For basic packaging classes, the default order of elements in the priority Queue is ascending, but for user-defined classes, you need to customize the comparison class Inter ...

Added by zz50 on Mon, 25 Oct 2021 06:45:39 +0300

Dynamic programming (js version)

1. Introduction to dynamic programming algorithm Understand dynamic programming ~ know a good article LeetCode's simple dynamic programming problem: Fibonacci numberclimb stairsClimb stairs with minimum costDifferent pathsDifferent paths II Summary: Dynamic programming is not so much an algorithm as a methodology. The methodology is mai ...

Added by tonbah on Sun, 24 Oct 2021 18:27:17 +0300

[problem solution] leetcode 1672. Total assets of richest customers, 1582. Special positions in binary matrix, 832. Flip image

832. Flip image https://leetcode-cn.com/problems/flipping-an-image/ Given a binary matrix A, we want to flip the image horizontally first, then reverse the image and return the result. Flip the picture horizontally is to flip each line of the picture, that is, in reverse order. For example, the result of flipping [1, 1, 0] horizontall ...

Added by sx on Sun, 24 Oct 2021 07:43:10 +0300