当前位置:网站首页>21st day of written test mandatory training
21st day of written test mandatory training
2022-07-24 03:18:00 【Curry won't throw three points】
choice question
- Although the single linked list can be located by binary search , But the insertion may only be head or tail , So you still need to traverse
![]()
- Loading factor = Valid elements / The length of the array , Load factor increases , There should be more effective elements , Or the array length becomes smaller , That one will increase the probability of conflict
Programming questions
![]()
- This problem is to find rules , After reading one number at a time , Figure out how he passed k Position after the second shuffle , Use only one length 2n Arrays are used to output According to the position of the current number , You can calculate the position after a shuffle if the current number is less than or equal to n( In the left hand ), Then the position of his next appearance is 2* The current position The corresponding current position + n( In the right hand ) The card of , Then the position of his next appearance is 2* The current position + 1
package days.day21; import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0){ int n=sc.nextInt(); int k=sc.nextInt(); int arr[]=new int[2*n]; for(int i=0;i<2*n;i++){ arr[i]=sc.nextInt(); } sort(arr,k,n); t--; } } public static void sort(int []arr,int k,int n){ for(int i=0;i<k;i++){ int newarr[]=new int[2*n]; for(int j=0;j<n;j++){ newarr[2*j]=arr[j]; newarr[2*j+1]=arr[j+n]; } arr=newarr; } for(int i=0;i<2*n;i++){ System.out.print(arr[i]); if(i!=2*n-1){ System.out.print(" "); } } System.out.println(); } }
- This problem is completely handled according to the situation , First, it is divided into two major situations 1 Characters less than or equal to 4( There will be no skipping to the last page , And the question on the first page , There is no need to deal with the problem of changing pages )2 Characters greater than or equal to 4
- Characters greater than or equal to 4 There are many kinds of situations 1 Skip from the first page to the last 2 Skip from the last page to the last page 3 Refresh the first line The whole page moves down one grid 4 Refresh the last line in , The whole page moves up one space 5 Normal cursor down , Do not refresh page 6 Normal cursor moves up , Do not refresh page
package days.day21; import java.util.*; public class Main2 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String str = sc.next(); char arr[] = str.toCharArray(); int now = 1; int list = 1; if (n <= 4) { for (int i = 0; i < arr.length; i++) { if (now == 1 && arr[i] == 'U') { now = n; } else if (now == n && arr[i] == 'D') { now = 1; } else if (arr[i] == 'U') { now--; } else if (arr[i] == 'D') { now++; } } for (int i = 1; i <= n; i++) { System.out.print(i + " "); } System.out.println(); System.out.println(now); } else { for (int i = 0; i < arr.length; i++) { // When the cursor is on the first line // If you go up, you need to change to the last page if (list == 1 && now == 1 && arr[i] == 'U') { list = n - 3; now = n; // When the cursor is on the last line // If you go down, you need to change to the first page } else if (list == n - 3 && now == n && arr[i] == 'D') { list = 1; now = 1; } else if (list != 1 && now == list && arr[i] == 'U') { list--; now--; } else if (list != n - 3 && now == list + 3 && arr[i] == 'D') { list++; now++; } else if (arr[i] == 'D') { now++; } else if (arr[i] == 'U') { now--; } } for (int i = list; i <= list + 3; i++) { System.out.print(i + " "); } System.out.println(); System.out.println(now); } } }
边栏推荐
- MySql的DDL和DML和DQL的基本语法
- C动态内存管理详解
- Unity Message push
- Hcip day 10 (initial BGP border gateway protocol)
- Take you into the world of MySQL mvcc
- Interviewer: if the order is not paid within 30 minutes after it is generated, it will be automatically cancelled. How to realize it?
- Example of producer consumer code implemented by the destructor framework without lock
- The error of van swipe in the rotation chart: cannot read a properties of null (reading width)
- [AMC] federal quantification
- JMeter interview script
猜你喜欢

CMT 注册——Google Scholar Id,Semantic Scholar Id,和 DBLP Id

SolidWorks cannot reference references

OSPF comprehensive experimental configuration

Industrial controller, do you really know your five insurances and one fund?

JS array isaarray() typeof
![[hdlbits questions] Verilog language (2) vectors](/img/eb/125c9a7781391dc53e37ce347a475d.png)
[hdlbits questions] Verilog language (2) vectors

Open source embedded sig in the openeuler community. Let's talk about its multi OS hybrid deployment framework

正则表达式 \b \B 深入浅出理解单词边界的匹配

Basic use of Pinia

C dynamic memory management details
随机推荐
MySql的DDL和DML和DQL的基本语法
Jump statements break and continue
Gpushare.com | 如何使用TensorBoardX可视化工具?
Expressions régulières \ \ B \ \ b compréhension de l'appariement des limites des mots
在openEuler社区开源的Embedded SIG,来聊聊它的多 OS 混合部署框架
1. Learn to understand web pages
Xiaodi and Xiaohui
Leetcode stack and queue questions
MariaDB related instructions
QT custom class uses custom parametric signals and slots
MySQL sub database and sub table and its smooth expansion scheme
Correct usage of iota in golang
Advantages, disadvantages and summary of sequence list and linked list
Huawei then responded to the rumor of "cleaning up employees over the age of 34". How can programmers cope with the "35 year old crisis"?
Error code 0x80004005
String.split()最详细源码解读及注意事项
Go log package
移动通信的新定义:R&SCMX500 将提高5G设备的IP数据吞吐量
Do the right thing, do it right
Lcd1602——斌哥51





