Ad
Code
Diff
  • function descendingOrder(n){
      let x= n.toString();
      let arr = x.split('');
      let N = arr.length;
      
      if (n.length === 1) {
        return parseInt(n, 10);
      }
      
      for (let i = 0; i < N; i++) {
        
        for (let j = 0; j < N-i-1; j++) {
           if (arr[j] < arr[j+1]) {
            let k = arr[j];
            arr[j] = arr[j+1];
            arr[j+1] = k;
          }
        }
      }
     
     	n = arr.join('');
      n = parseInt(n, 10);
      return n;
    }
    • function descendingOrder(n){
    • n = n.toString();
    • let arr = n.split('');
    • let x= n.toString();
    • let arr = x.split('');
    • let N = arr.length;
    • if (n.length === 1) {
    • return parseInt(n, 10);
    • }
    • for (let i = 0; i < N; i++) {
    • for (let j = 0; j < N-i-1; j++) {
    • if (arr[j] < arr[j+1]) {
    • let k = arr[j];
    • arr[j] = arr[j+1];
    • arr[j+1] = k;
    • }
    • }
    • }
    • n = arr.join('');
    • n = parseInt(n, 10);
    • return n;
    • }
Code
Diff
  • const main = () => {
      const links = [
        'https://www.uol',
        'https://www.bol.com.br',
        'https://www.uol',
        'https://noticias.uol.com.br',
        'https://www.bol.com.br',
      ];
      
      // converter para ES6
      function uniqueLinks (links){
        return uniqueLinks.length;
      }
    };
    • const main = () => {
    • const links = [
    • 'https://www.uol',
    • 'https://www.bol.com.br',
    • 'https://www.uol',
    • 'https://noticias.uol.com.br',
    • 'https://www.bol.com.br',
    • ];
    • // converter para ES6
    • const uniqueLinks = new Set(links);
    • return uniqueLinks.length;
    • function uniqueLinks (links){
    • return uniqueLinks.length;
    • }
    • };
Code
Diff
  • function reverseInt(n) {
        let reversed = 0;
        
        while(n >= 0){
          reversed = reversed * 10 + (n % 10);
          n /= 10;
        }
        
        return reversed;
      }
    }
    • public class Algorithms {
    • public static int reverseInt(int n) {
    • int reversed = 0;
    • function reverseInt(n) {
    • let reversed = 0;
    • while(n != 0){
    • while(n >= 0){
    • reversed = reversed * 10 + (n % 10);
    • n /= 10;
    • }
    • return reversed;
    • }
    • }