본문 바로가기

알고리즘

(176)
[LeetCode] 20. Valid Parentheses Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Example 1: Input: s = "()" Output: true Example 2: Input: s = "()[]{}" Output: true Example 3: Input: s = "(]" Output: false Example 4: In..
[Hackerrank] Scope Objective Today we're discussing scope. Check out the Tutorial tab for learning materials and an instructional video! The absolute difference between two integers, and , is written as . The maximum absolute difference between two integers in a set of positive integers, , is the largest absolute difference between any two integers in . The Difference class is started for you in the editor. It has..
[Programmers] [1차] 다트게임 문제 설명 다트 게임 카카오톡에 뜬 네 번째 별! 심심할 땐? 카카오톡 게임별~ 카카오톡 게임별의 하반기 신규 서비스로 다트 게임을 출시하기로 했다. 다트 게임은 다트판에 다트를 세 차례 던져 그 점수의 합계로 실력을 겨루는 게임으로, 모두가 간단히 즐길 수 있다. 갓 입사한 무지는 코딩 실력을 인정받아 게임의 핵심 부분인 점수 계산 로직을 맡게 되었다. 다트 게임의 점수 계산 로직은 아래와 같다. 다트 게임은 총 3번의 기회로 구성된다. 각 기회마다 얻을 수 있는 점수는 0점에서 10점까지이다. 점수와 함께 Single(S), Double(D), Triple(T) 영역이 존재하고 각 영역 당첨 시 점수에서 1제곱, 2제곱, 3제곱 (점수1 , 점수2 , 점수3 )으로 계산된다. 옵션으로 스타상(*) ,..
[Hackerrank] Abstract Classes Objective Today, we will extend what we learned yesterday about Inheritance to Abstract Classes. Because this is a very specific object oriented concept, submissions are limited to the few languages that use this construct. Check out the Tutorial tab for learning materials and an instructional video. Task Given a Book class and a Solution class, write a MyBook class that does the following: Inhe..
[Hackerrank] Ingeritance Objective Today, we're delving into Inheritance. Check out the attached tutorial for learning materials and an instructional video. Task You are given two classes, Person and Student, where Person is the base class and Student is the derived class. Completed code for Person and a declaration for Student are provided for you in the editor. Observe that Student inherits all the properties of Perso..
[Hackerrank] 2D Arrays Objective Today, we are building on our knowledge of arrays by adding another dimension. Check out the Tutorial tab for learning materials and an instructional video. Context Given a 2D Array, : 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation: a b c d e f..
[Hackerrank] Binary Numbers Objective Today, we're working with binary numbers. Check out the Tutorial tab for learning materials and an instructional video! Task Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation. When working with different bases, it is common to show the base as a subscript. Example The bi..
[Hackerrank] Recursion 3 Objective Today, we are learning about an algorithmic concept called recursion. Check out the Tutorial tab for learning materials and an instructional video. Recursive Method for Calculating Factorial Function Description Complete the factorial function in the editor below. Be sure to use recursion. factorial has the following paramter: int n: an integer Returns int: the factorial of n Note: If ..