We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 6: Let's Review
  5. Discussions

Day 6: Let's Review

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 3200 Discussions, By:

recency

Please Login in order to post a comment

  • rjdavies24
    23 minutes ago+ 0 comments

    Instructions explicitly state that the solution is to have 2 spaces between the strings. Solution is looking for 1 space between the strings. Please fix.

    0|
    Permalink
  • teymurnasir
    2 days ago+ 0 comments

    Here is my JavaScript solution:

    function processData(input) {
        //Enter your code here
        let words = input.split('\n').slice(1);
        
        for(var i=0;i<words.length;i++){
            var word = words[i];
            var evenLetters= '';
            var oddLetters = '';
            for(var j=0;j<word.length;j++){
                if(j==0 || j%2==0){
                    evenLetters += word[j];
                }else{
                    oddLetters += word[j];
                }
            }
            console.log(evenLetters+' '+oddLetters);
        }
    } 
    
    0|
    Permalink
  • srikanthgade1818
    4 days ago+ 0 comments

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner scn=new Scanner(System.in);
    
        int t=scn.nextInt();
       //scn.nextLine();
        for(int j=0;j<=t;j++){
        String s=scn.next();
        String even="";
        String odd="";
        for(int i=0;i<s.length();i++){
            if(i%t==0){
                even+=s.charAt(i);
                //System.out.println(even);
                }
            else {
             odd+=s.charAt(i);}//System.out.println(even+" "+odd);
        }
                         System.out.println(even+" "+odd);      any one check this code i got a reun time expectation i go
    
        }
    
        }
    

    }

    0|
    Permalink
  • lebaodai2611
    6 days ago+ 0 comments

    My code Python 3

    n = int(input())
    for _ in range(n):
        s = input()
        print(s[::2] + ' ' + s[1::2]) 
    
    0|
    Permalink
  • barunkr0801
    1 week ago+ 1 comment

    My solution is giving the error (shown below) in hackerrank. However, it's executing fine on my pc.

    Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1585) at Solution.main(Solution.java:14)

    Here is my code :-

    import java.io.*;
    import java.util.*;
     
    public class Solution {
     
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            //sc.close();
            String[] s = new String[n];
            Scanner sc1 = new Scanner(System.in);
            for(int i = 0 ; i < n ; i++){
                s[i]= new String();
                s[i] = sc1.nextLine();
            }
            for(int i = 0 ; i < n ; i++){
               int l = s[i].length();
                for(int j = 0 ; j < l ; j++){
                    System.out.print(s[i].charAt(j));
                    j++;
                }
                System.out.print(" ");
                for(int j = 1 ; j < l ; j++){
                    System.out.print(s[i].charAt(j));
                    j++;
                }
                System.out.println();
            }
      }
    }
     
    
    0|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy