본문 바로가기

Algorithm24

Recursion: Davis' Staircase 풀이 Java Recursion: Davis' Staircase | HackerRank Recursion: Davis' Staircase | HackerRank We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies. www.hackerrank.com Recursion and Backtracking에 DP를 살짝 얹은 문제 피보나치와 비슷하게 공식을 만들면 되지만, n이 커지는 경우를 생각해서 DP를 사용해야 한다. return stepPerms(n - 1) + stepPerms(n - 2) + st.. 2022. 7. 10.
Strings: Making Anagrams java 풀이 Strings: Making Anagrams | HackerRank How many characters should one delete to make two given strings anagrams of each other? www.hackerrank.com 시간복잡도 참고 https://hbase.tistory.com/185 [Java] 컬렉션들의 시간복잡도 (Collection Big-O) 자바를 이용해서 알고리즘 문제를 풀거나 큰 사이즈의 데이터를 다룰 때, 컬렉션들의 정확한 시간복잡도(Big-O)를 알고 사용하는 것이 중요하다. 자칫 불필요하게 느린 컬렉션이나 메소드를 사용 hbase.tistory.com list.contains의 시간복잡도는 O(n) 이기 때문에 내 풀이의 시간복잡도는 O(n^.. 2022. 7. 9.
Codility : GenomicRangeQuery 풀이 문제 GenomicRangeQuery coding task - Learn to Code - Codility Find the minimal nucleotide from a range of sequence DNA. app.codility.com A DNA sequence can be represented as a string consisting of the letters A, C, G and T, which correspond to the types of successive nucleotides in the sequence. Each nucleotide has an impact factor, which is an integer. Nucleotides of types A, C, G and T have impa.. 2022. 3. 5.
Codility : MaxSliceSum 풀이 Java, DP 문제 MaxSliceSum coding task - Learn to Code - Codility Find a maximum sum of a compact subsequence of array elements. app.codility.com A non-empty array A consisting of N integers is given. A pair of integers (P, Q), such that 0 ≤ P ≤ Q < N, is called a slice of array A. The sum of a slice (P, Q) is the total of A[P] + A[P+1] + ... + A[Q]. Write a function: class Solution { public int solution(in.. 2022. 3. 5.
Codility : Greedy MaxNonoverlappingSegments 풀이 Java, Greedy 알고리즘 문제 MaxNonoverlappingSegments coding task - Learn to Code - Codility Find a maximal set of non-overlapping segments. app.codility.com Located on a line are N segments, numbered from 0 to N − 1, whose positions are given in arrays A and B. For each I (0 ≤ I < N) the position of segment I is from A[I] to B[I] (inclusive). The segments are sorted by their ends, which means that B[K] ≤ B[K + 1] for K.. 2022. 3. 4.
Codility : Leader Dominator 풀이 Java, HashMap entrySet 문제 Dominator coding task - Learn to Code - Codility Find an index of an array such that its value occurs at more than half of indices in the array. app.codility.com An array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elements of A. For example, consider array A such that A[0] = 3 A[1] = 4 A[2] = 3 A[3] = 2 A[4] = 3 A[5] = -1 A[.. 2022. 3. 3.
반응형