(C language) stack and queue experiment

1. (1): judge whether open parentheses and closed parentheses in an arithmetic expression are paired. Implementation code: #include <stdio.h> #include <stdlib.h> #define MAXSIZE 100 typedef struct{ char data[MAXSIZE]; int top; }seqstack; int MatchCheck(char str[]){ seqstack s; int i = 0; s.top = -1; while (str[i] != '\0'){ ...

Posted by lou28 on Fri, 22 Oct 2021 23:02:39 -0700

[SHA256 of security algorithm] C language source code implementation of SHA256 abstract operation

summary As we all know, the summary algorithm is also a particularly important existence in the security field, and SHA256 is one of the most common summary algorithms. Its characteristic is that it has low computational complexity. The equal length summary value can be obtained by inputting the original text of unequal length data, which ...

Posted by stuartc1 on Fri, 22 Oct 2021 20:04:40 -0700

LeetCode buckle biweekly 63

The happiest thing at the weekend is to fill in questions and write solutions to cook for his wife. Weekly portal 2037. Make each student have the minimum number of seat movements Idea: greed Time complexity: O ( n ∗ ...

Posted by jxrd on Fri, 22 Oct 2021 19:50:27 -0700

LeetCode 18. Sum of four numbers

LeetCode 18. Sum of four numbers Title: Give you an array of n integers, nums, and a target value, target. Please find and return the quads [nums[a], nums[b], nums[c], nums[d]]: 0 <= a, b, c, d < na. b, c and d are different from each othernums[a] + nums[b] + nums[c] + nums[d] == target You can return answers in any order. Example: ...

Posted by thetick on Fri, 22 Oct 2021 13:08:45 -0700

Python data structure and algorithm -- search and sort

search 1. Sequential search Through subscripts, we can access and search data items in order. This technology is called "sequential search" def sequentialSearch(alist,item): pos = 0 found = False while pos<len(alist) and not found: if alist[pos] == item: found = True else: ...

Posted by renzaho on Fri, 22 Oct 2021 02:47:21 -0700

[excellent research question] [rmq] [suffix array] Maximum repetition substring POJ3693

The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same consecutive substrings. For example, the repetition number of "ababab" is 3 and "ababa" is 1. Given a string containing lowercase letters, you are to find a substring of it with maximum repetition number. Input The input c ...

Posted by ereptur on Fri, 22 Oct 2021 01:05:13 -0700

Standard template library for solving algorithm problems

Monotone stack handles the problem of size comparison in the overall O(n) time by maintaining the monotonic increment (decrement) of the value in the stack. 739 daily temperature Given the daily temperature, it is required to wait a few days for each day to wait for a warmer day. If there is no warmer weather after that day, it is recorded as ...

Posted by r3dk1t on Thu, 21 Oct 2021 22:53:03 -0700

Algorithm learning Day01

Tip: after the article is written, the directory can be generated automatically. Please refer to the help document on the right for how to generate it 1, What is the time complexity? The algorithm takes the highest order after adding the calculation times, ignoring the constant and the rest If sorting is selected, n+n-1+n-2 + The calcu ...

Posted by shylock on Thu, 21 Oct 2021 22:36:13 -0700

[algorithm] 1. Let's start with the simplest selection sorting

Write in front I've been busy with my work in the past two months and haven't taken time to take care of my blog. It's rare to take a day off today. I want to review a little bit from the most basic algorithm, and constantly improve my study while reviewing. I want to implement my own small algorithm library by the end of May next year. W ...

Posted by codepoet on Thu, 21 Oct 2021 11:06:02 -0700

PTA --- greedy algorithm

7-1 packing problem import java.util.Scanner; public class Program1 { public static void main(String[] args) { int N; Scanner in = new Scanner(System.in); N = in.nextInt(); int []things = new int[N]; //Up to N boxes int []box = new int[N]; //Record the maximum number of boxes ...

Posted by webbnino on Wed, 20 Oct 2021 20:33:54 -0700