Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
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;
    }
  • 11 function descendingOrder(n){
    2- n = n.toString();
    3- let arr = n.split('');
    2+ let x= n.toString();
    3+ let arr = x.split('');
    44 let N = arr.length;
    55
    66 if (n.length === 1) {
    77 return parseInt(n, 10);
    88 }
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;
      }
    };
  • 11 const main = () => {
    22 const links = [
    33 'https://www.uol',
    44 'https://www.bol.com.br',
    55 'https://www.uol',
    66 'https://noticias.uol.com.br',
    77 'https://www.bol.com.br',
    88 ];
    99
    1010 // converter para ES6
    11- const uniqueLinks = new Set(links);
    12-
    13- return uniqueLinks.length;
    11+ function uniqueLinks (links){
    12+ return uniqueLinks.length;
    13+ }
    1414 };
Code
Diff
  • function reverseInt(n) {
        let reversed = 0;
        
        while(n >= 0){
          reversed = reversed * 10 + (n % 10);
          n /= 10;
        }
        
        return reversed;
      }
    }
  • 1-public class Algorithms {
    2- public static int reverseInt(int n) {
    3- int reversed = 0;
    1+function reverseInt(n) {
    2+ let reversed = 0;
    44
    5- while(n != 0){
    4+ while(n >= 0){
    66 reversed = reversed * 10 + (n % 10);
    77 n /= 10;
    88 }
    99
    1010 return reversed;
    1111 }
    1212 }