hackerrank.com
-
Java 1D Array (Part 2) / hackerrank.comhackerrank.com 2019. 12. 10. 18:07
hackerrank.com 의 Java 1D Array (Part 2) 문제를 풀어 보겠습니다. 문제 링크 : https://www.hackerrank.com/challenges/java-1d-array/problem 답 코드 링크 : https://github.com/skysign/WSTT/blob/master/hackerrank/Java%201D%20Array%20(Part%202)/src/com/tistory/skysign/hackerrank/Java_1D_Array_Part_2/Main.java Discussion에 보면, loop를 사용해서 풀이도 가능한 것으로 보이지만, 요즘 Dynamic Programming을 공부중이기도 하고, 문제를 봤을 때, DP로 풀어보는 방법이 떠올라서, DP로 풀..
-
Hackerrank.com Practice>Java>Advanced>Java Singleton Patternhackerrank.com 2019. 12. 2. 13:36
Singleton Pattern을 이해하고 있는지에 대해서 묻는 문제 입니다. import java.io.*; import java.util.*; import java.lang.reflect.*; class Singleton{ private Singleton() {} private volatile static Singleton instance; public String str; static Singleton getSingleInstance() { if(null == instance) { synchronized(Singleton.class) { if(null == instance) { instance = new Singleton(); } } } return instance; } }이렇게 구현하는 것이 가장..
-
Practice>Python>Built-Ins>Athlete Sorthackerrank.com 2019. 5. 1. 16:17
hackerrank.com Athlete Sort Problem Link : https://www.hackerrank.com/challenges/python-sort-sort/problem Difficulty : Medium Tip Using itemgetter() as key for sorted() function, is important to solve Solution #!/bin/python3 import math import os import random import re import sys from operator import itemgetter mn = input().split() m = int(mn[0]) n = int(mn[1]) arr = [] for _ in range(m): arr.a..
-
Practice>Python>Regex and Parsing>Matrix Scripthackerrank.com 2019. 4. 29. 21:48
hackerrank.com Matrix Script Problem Link : https://www.hackerrank.com/challenges/matrix-script/problem Difficulty : Hard Tip MUST remove __main__, it lead to fail even correct answer, because there is 'if' Should use regular expression Lookahead and lookbehind Write regular expression, to capture [alphabet][symboles][alphabet] Solution #!/bin/python3 import math import os import random import r..
-
Practice>Python>Built-Ins>ginortShackerrank.com 2019. 4. 29. 13:00
hackerrank.com ginortS Problem Link : https://www.hackerrank.com/challenges/ginorts/problem Difficulty : Medium Tip We should sort as per four groups myfilter() function is written to get four gourps. Sort each groups and concate them Solution s = input() def myfilter(s): lc = [] wc = [] on = [] en = [] for i in range(len(s)): c = s[i] if 'a'
-
Practice>Python>Regex and Parsing>Validating Credit Card Numbershackerrank.com 2019. 4. 26. 12:47
hackerrank.com Validating Credit Card Numbers Problem Link : https://www.hackerrank.com/challenges/validating-credit-card-number/problem Difficulty : Medium Tip It's a bit difficult to solve only using regular expression Especially, 'NOT have or more consecutive repeated digits' More over, in test case 6, '-------' is given as a part of input, it should be filtered, also Check condition 1~4 by u..