Algorithm

    [Codility] Algorithmic skills. FirstUnique

    https://app.codility.com/programmers/trainings/4/first_unique/ A non-empty array A consisting of N integers is given. The unique number is the number that occurs exactly once in array A. For example, the following array A: A[0] = 4 A[1] = 10 A[2] = 5 A[3] = 4 A[4] = 2 A[5] = 10 contains two unique numbers (5 and 2). You should find the first unique number in A. In other words, find the unique nu..

    [프로그래머스] 완전탐색. 수포자

    https://programmers.co.kr/learn/courses/30/lessons/42840 문제 설명 수포자는 수학을 포기한 사람의 준말입니다. 수포자 삼인방은 모의고사에 수학 문제를 전부 찍으려 합니다. 수포자는 1번 문제부터 마지막 문제까지 다음과 같이 찍습니다. 1번 수포자가 찍는 방식: 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ... 2번 수포자가 찍는 방식: 2, 1, 2, 3, 2, 4, 2, 5, 2, 1, 2, 3, 2, 4, 2, 5, ... 3번 수포자가 찍는 방식: 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, ... 1번 문제부터 마지막 문제까지의 정답이 순서대로 들은 배열 answers가 주어졌을 ..

    [Hackerrank] Strings. Java String Reverse

    https://www.hackerrank.com/challenges/java-string-reverse/problem A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Given a string A, print Yes if it is a palindrome, print No otherwise. Constraints A will consist at most 50 lower case english letters. Sample Input madam Sample Output Yes 쉬운 문제입니다. 문자열이 palindrome(거꾸로 읽어도 동일한 문자열)일 ..

    [프로그래머스] 탐욕법(Greedy). 체육복

    https://programmers.co.kr/learn/courses/30/lessons/42862 점심시간에 도둑이 들어, 일부 학생이 체육복을 도난당했습니다. 다행히 여벌 체육복이 있는 학생이 이들에게 체육복을 빌려주려 합니다. 학생들의 번호는 체격 순으로 매겨져 있어, 바로 앞번호의 학생이나 바로 뒷번호의 학생에게만 체육복을 빌려줄 수 있습니다. 예를 들어, 4번 학생은 3번 학생이나 5번 학생에게만 체육복을 빌려줄 수 있습니다. 체육복이 없으면 수업을 들을 수 없기 때문에 체육복을 적절히 빌려 최대한 많은 학생이 체육수업을 들어야 합니다. 전체 학생의 수 n, 체육복을 도난당한 학생들의 번호가 담긴 배열 lost, 여벌의 체육복을 가져온 학생들의 번호가 담긴 배열 reserve가 매개변수로 주어..

    [프로그래머스] 해시. 완주하지 못한 선수

    https://programmers.co.kr/learn/courses/30/lessons/42576 문제 설명 수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다.마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수들의 이름이 담긴 배열 completion이 주어질 때, 완주하지 못한 선수의 이름을 return 하도록 solution 함수를 작성해주세요. 제한사항 - 마라톤 경기에 참여한 선수의 수는 1명 이상 100,000명 이하입니다. - completion의 길이는 participant의 길이보다 1 작습니다. - 참가자의 이름은 1개 이상 20개 이하의 알파벳 소문자로 이루어져 있습니다.참가자 중에는 동명이인..

    [LeetCode] 1528. Shuffle String

    Given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return the shuffled string. Example 1: Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3] Output: "leetcode" Explanation: As shown, "codeleet" becomes "leetcode" after shuffling. Example 2: Input: s = "abc", indice..

    [LeetCode] 66. Plus One

    Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit. You may assume the integer does not contain any leading zero, except the number 0 itself. Example 1: Input: digits = [1,2,3] Output: [1,2,4] Explan..