Skip to content

Rainmore

Enjoy every single moment of my life

Recent Posts

  • Renew Let’s Encrypt
  • Spring RequestMapping Regx
  • Ubuntu Reconfigure Locale
  • How to Extract the Private and Public Key From pfx File
  • Install zsh

Recent Comments

    Archives

    • March 2019
    • February 2019
    • November 2018
    • September 2018
    • August 2018
    • July 2018
    • June 2018
    • May 2018

    Categories

    • Algorithm
    • Docker
    • Haskell
    • Java 8
    • Linux
    • MongoDB
    • MySQL
    • Uncategorized

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Tag: algorithm

    Codility MissingInteger, Java 8

    import java.util.Set;
    import java.util.stream.Collectors;
    import java.util.stream.IntStream;
    
    private static void getResult(int[] a) {
        Set set = IntStream.of(a).boxed().collect(Collectors.toSet());
    
        int result = 1;
        while(set.contains(result)) {
            result++;
        }
    
        return result;
    }
    

    Reference: https://stackoverflow.com/questions/26532081/codility-missinginteger-java

    Posted on 2018-05-052018-05-06Categories AlgorithmTags algorithm, java8
    Proudly powered by WordPress