# All# python# wedfg# scope variable# interview# lexical environment# javascript# #algorithm# hoisting# good# print# java# coding shortcut# competitive coding# shorthand# loop tricks# sample# #c# gambling# primitives# algoritms# arrow-functions# javascriptintro# usefullinks# technical round# project# beetroot# reverse# array# copy# collection# test# i am printing hello world# #class# #js# #interview

Latest from community today

class chain {
  constructor() {
    this.num = 0
  }

  init(number) {
    this.num = number
    return this
  }

  add(number) {
    this.num += number
    return this
  }

  sub(number) {
    this.num -= number
    return this
  }

  get() {
    return this.num
  }
}
const counter = new chain()

const ans = counter.init(100).add(11).sub(1).get()
console.log(ans)
import java.util.*;

class Solution {
    static Integer[] rev(Integer arr[]) {
        Integer[] temp = arr.clone();
        Collections.reverse(Arrays.asList(temp));
        return temp;
    }
    
    public static void main(String[] args) {
        Integer[] arr = new Integer[]{1, 2, 3, 4, 5};

        // reverse the copy
        Integer[] revArr = rev(arr);
        
        System.out.print("Your items: ");
        for (int item:arr) {
            System.out.print(item +" ");
        }
        System.out.println();
        System.out.print("Reversed items: ");
        for (int item:revArr) {
            System.out.print(item +" ");
        }
        
    }
}

class Solution {
    static int[] rev(int arr[]) {
        int[] temp = new int[arr.length];
        int j=0;
        for(int i=arr.length-1; i>=0; i--) {
            temp[j] = arr[i];
            j++;
        }
        return temp;
    }
    
    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 4, 5};

        // reverse the copy
        int[] revArr = rev(arr);
        
        System.out.print("Your items: ");
        for (int item:arr) {
            System.out.print(item +" ");
        }
        System.out.println();
        System.out.print("Reversed items: ");
        for (int item:revArr) {
            System.out.print(item +" ");
        }
        
    }
}

class Solution {
    static void rev(int arr[]) {
        for(int i=0; i<Math.floor(arr.length/2); i++) {
            int temp = arr[i];
            arr[i] = arr[arr.length - 1 - i];
            arr[arr.length - 1 - i] = temp;
        }
    }
    
    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 4, 5};

        System.out.print("Before reverse: ");
        for (int item:arr) {
            System.out.print(item +" ");
        }
        
        System.out.println();
        // reverse the source array
        rev(arr);
        
        System.out.print("After reverse: ");
        for (int item:arr) {
            System.out.print(item +" ");
        }
        
    }
}
<?php

$query = new WP_Query([
    'post_type' => 'regions',
    'country' => 'ukraine'
]);

if ($query->have_posts()) {
    while ($query->have_posts()) {
        $query->the_post();
        $region = get_the_title();
        $pattern = get_the_content();
        draw($region, $pattern);
    }
}

Featured content