HackerRank Tweets

Sort by

recency

|

97 Discussions

|

  • + 0 comments

    Java 15

    import java.io.*;
    import java.util.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    public class Solution {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = Integer.parseInt(scanner.nextLine());
            Pattern pattern = Pattern.compile("hackerrank",Pattern.CASE_INSENSITIVE);
            int count=0;
            for(int i=0;i<n;i++)
            {   Matcher matcher = pattern.matcher(scanner.nextLine());
                if (matcher.find()) count++;
            }
            System.out.println(count);
        }
    }
    
  • + 0 comments

    Python 3

    import re
    n = int(input())
    counter = 0
    for _ in range(n):
        tweet = input()
        if re.search(r"hackerrank", tweet, re.IGNORECASE):
            counter += 1
    print(counter)
    
  • + 0 comments

    Javascript:

    const lines = input.match(/^.*?\bhackerrank\b.*?$/gmi);
    console.log(lines.length);
    
  • + 0 comments

    As a oneliner:

    print(sum(1 if 'hackerrank' in input().lower() else 0 for _ in range(int(input()))))
    
  • + 0 comments

    Procedural programming is the best (jk)

    n = int(input())
    
    c = 0
    for _ in range(n):
        tweet = input().lower()
        if 'hackerrank' in tweet:
            c += 1
    print(c)