884. Unusual words in two sentences / 1544 Collating Strings / 1512 Number of good pairs

884. Unusual words in two sentences [simple question] [daily question] Idea: [hash table simulation] Define two hash tables to store each word and occurrence times of s1 and s2 respectively.Define a list to store the uncommon words found.Traverse all the keys of map1. If value=1 and does not appear in map2, then this key is an uncommon wor ...

Posted by mistertylersmith on Thu, 03 Feb 2022 15:16:29 +0100

Leetcode algorithm interview sprint practice 11 (queue)

40. Implement queue with stack As stated in the title, you can only use two stacks to implement some operations of the queue. The queue should support push(element), pop() and top(), where pop is the first (foremost) element in the pop-up queue. Both pop and top methods should return the value of the first element. class MyQueue: ...

Posted by rcarr on Thu, 03 Feb 2022 09:56:47 +0100

[LeetCode] - hash table

preface When I first know LeetCode and algorithm, I will record my algorithm learning experience in this series of articles. In the early stage, I mainly supervise my learning and clock in. In the later stage, I will slowly add my understanding of knowledge to the articles. I hope you can gain something from reading my articles. The order ...

Posted by hoboman on Thu, 03 Feb 2022 08:15:49 +0100

Prepare for the second test, three questions a day, Day26

Prepare for the second test, three questions a day Topic 1: square root of x Give you a nonnegative integer x, calculate and return the arithmetic square root of X. Since the return type is an integer, only the integer part will be retained and the decimal part will be rounded off. Note: it is not allowed to use any built-in exponential fun ...

Posted by orion2004 on Thu, 03 Feb 2022 06:45:36 +0100

Novice queue (example)

Queue learning can be compared to stack learning. Queue is an important data structure to realize breadth first search.   queue<int> aa; //Define a queue -Basic operation of queue—— aa.front() //Returns the first element of the queue aa.back() //Returns the last element of the queue aa.empty() //Returns true if the qu ...

Posted by BlaineSch on Wed, 02 Feb 2022 22:29:50 +0100

Advanced pointer

Some error points about pointers: The address of the first element is passed, not the whole array.   About pointer printing: You can use an array or a pointer to print. The pointer will look for the last '\ 0' as the end.   The first dereference print is c. the following print is abcdef It cannot be modif ...

Posted by juancarlosc on Wed, 02 Feb 2022 20:20:23 +0100

BFS and DP -- the 70th biweekly match of Li Kou

⭐ New pit in winter vacation -- daily question notes of code Fox First question, greedy thought (take the largest two at a time, and then the largest third for free - the amount of sugar you can take for free is limited. Why not take one expensive one for free) The second problem is mathematical thinking (all numbers are in a range, so you onl ...

Posted by sparrrow on Wed, 02 Feb 2022 18:05:46 +0100

#21_ Day 21 (25)

I'll give you a linked list. Each group of k# nodes will be flipped. Please return to the flipped linked list. k is a positive integer whose value is less than or equal to the length of the linked list. If the total number of nodes is not an integer multiple of k , keep the last remaining nodes in the original order. Advanced: Can you desi ...

Posted by marcth on Wed, 02 Feb 2022 16:14:37 +0100

LeetCode 84: the largest rectangle in the histogram (difficult)

LeetCode 84: the largest rectangle in the histogram answer These two monotonous problems need to be reflected. Why are the ideas generally correct but have not been done Code one The first mock exam is to imitate the double pointer in rain water. In the rain water, find the highest column on the left and right sides of val, and take min ...

Posted by j.bouwers on Wed, 02 Feb 2022 10:39:51 +0100

Prefix and brush question summary of leetcode 1

Prefix and brush question summary of leetcode 1 1 - subarray with the smallest length Title Link: Title Link stamp here!!! Idea: prefix and + binary search Find the prefix sum of the array, find and update the smallest sub array in the prefix sum The AC code is as follows: class Solution { public int minSubArrayLen(int target, int[] num ...

Posted by imran.rajani on Wed, 02 Feb 2022 09:10:22 +0100