[data structure Java version] play with linked list interview questions and personal question solutions

1. Delete all nodes in the linked list equal to the given value val OJ link class Solution { public ListNode removeElements(ListNode head, int val) { if(head==null){ return null; } ListNode prev=head; ListNode cur=head.next; while(cur!=null){ if(cur.val==val){ ...

Posted by ofaltins on Sun, 05 Sep 2021 07:01:49 +0200

OJ online programming common input and output

A The input includes two positive integers a, B (1 < = a, B < = 10 ^ 9), and the input data includes multiple groups. Output Description: Output the result of a+b Example 1 input 1 5 10 20 output 6 30 import java.util.Scanner; public class Main1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ...

Posted by shdt on Sat, 04 Sep 2021 20:54:48 +0200

Sequential queue, cyclic queue, chain queue

preface Queue is a "first in, first out" linear table. Only one end of the table is inserted (queued), which is called the end of the queue, and the other end is deleted (queued), which is called the opposite end, that is, "tail in, head out". Only the head and tail of the queue can be accessed by the outside world, s ...

Posted by pacholo on Sat, 04 Sep 2021 04:38:24 +0200

Basic data structure - stack (implemented in c language)

Basic data structure - stack Stack is a last in, first out linear table. It is the most basic data structure and has applications in many places. What is stack Stack is a linear table that restricts insertion and deletion to only one location. Among them, the end that allows insertion and deletion is located at the end of the table, which is ...

Posted by jodyanne on Fri, 03 Sep 2021 04:15:14 +0200

java implementation of a simple binary tree, job hopping byte jump

2, Binary tree 1. Definition of binary tree A binary tree is a tree structure in which each node has at most two subtrees. It has five basic forms: binary tree can be an empty set; The root can have an empty left subtree or right subtree; Or the left and right subtrees are empty. 2. Properties of binary tree Property 1: the maximum number ...

Posted by mashamit on Thu, 02 Sep 2021 22:32:54 +0200

Data structure stack

1. DS stack - output in reverse order (used by STL stack) Title Description C + + has its own stack object stack, so there is no need to write the specific implementation code of stack operation. This topic mainly helps you to be familiar with the use of stack object, and then realize the reverse order output of string Enter a string, p ...

Posted by leoo24 on Thu, 02 Sep 2021 19:13:04 +0200