Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = [
- '7 4',
- '1 5 4 7',
- ]
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- const arr1 = gets().split(' ').map(Number);
- const arr2 = gets().split(' ').map(Number);
- const n = arr1[0];
- const k = arr2[1];
- class List {
- constructor() {
- this.items = []
- }
- add(item) {
- this.items.push(item);
- }
- get(index) {
- return this.items[index];
- }
- set(index, item) {
- return this.items[index] = item;
- }
- insert(index, item) {
- this.items.splice(index, 0, item);
- }
- remove(index) {
- this.items.splice(index, 1);
- }
- size() {
- return this.items.length;
- }
- values() {
- return [...this.items];
- }
- }
- let res = new List();
- for (let i = 1; i <= n; i++) {
- res.add(i);
- }
- print(res.values());
Advertisement
Add Comment
Please, Sign In to add comment