목록전체 글 (42)
mjk study log

The website: https://hwawon.pythonanywhere.com/ Campus Bloom화원에 대해 화원은 배움에는 끝이 없다고 믿습니다. 화원에서는 누구나 새로운 기술을 배우고, 다양한 사람들과 소통하며, 배움의 즐거움을 다시 발견할 수 있도록 따뜻하고 힐링이 되는 환경hwawon.pythonanywhere.com Why Pythonanywhere? / 왜 Pythonanywhere인가?무료이다! 물론 제공해주는 cpu가 적어 느리고 적은 양의 파일만 업로드 가능하지만 웹사이트를 처음 배포해보는 용이나 프로젝트 용으로는 딱 알맞다.Pythonanywhere 계정 만들기 1. https://www.pythonanywhere.com/에 접속해 회원가입을 해준다.1-a. 이때 주의할 점은..
Bellman-Ford algorithm computes the shortest path in a graph.- It also returns undefined when a path is cyclic- It takes O(VE), E could be V^2 (E = V^2), so O(V^3)-> So when you have a chance, use Dijkstra; use Bellman-Ford with potential negative weight cycles Generic Shortest Path Algorithm : (s = source, PI = predecessors)- initialize d[v] = infinite, PI[v] = NULL- set d[s] = 0// main loop: ..
문제https://www.hackerrank.com/challenges/special-palindrome-again/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=strings Special String Again | HackerRankFind Special sub-strings in a string.www.hackerrank.com 풀이특정 패턴이 있는 string 을 찾는 문제이다.모든 characters in the string을 기준으로 바로 옆의 char와 같은 지 (case 1), 왼쪽과 오른쪽이 같은 지 (case 2) 비교하여 총 개수를 세면 된..
문제https://www.hackerrank.com/challenges/ctci-merge-sort/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=sorting Merge Sort: Counting Inversions | HackerRankHow many shifts will it take to Merge Sort an array?www.hackerrank.com 풀이minimum swaps 2 와 비슷한 문제라 비슷한 방식으로 풀면 되겠지 라고 생각했지만,minimum swaps 2에서는 숫자가 한번씩 반복되며, 착하게 1에서부터 n 까지 나온다.하지만 이 ..
문제https://www.hackerrank.com/challenges/fraudulent-activity-notifications/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=sorting Fraudulent Activity Notifications | HackerRankPrint the number of times a customer receives a notificationwww.hackerrank.com 풀이median 을 구하는 방법을 파악하는게 이 문제의 메인이다. 처음(코드1)에는 d개의 숫자를 sort해서 가운데의 2개의 숫자의 합이나 1개의 ..
문제https://www.hackerrank.com/challenges/frequency-queries/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps Frequency Queries | HackerRankProcess the insert/delete queries and report if any integer is there with a particular frequency.www.hackerrank.com 풀이원래는 int freq[10^9+1] = {0} 를 사용해 x,y,z가 나오는데로 frequency를 updat..
문제https://www.hackerrank.com/challenges/count-triplets-1/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps Count Triplets | HackerRankReturn the count of triplets that form a geometric progression.www.hackerrank.com 풀이 hashmap을 사용하지 않으면 time limit exceed 가 뜬다.이 문제에서는 총 2개의 hash map을 사용하는데, triplet이 (first, second, th..
문제https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps Sherlock and Anagrams | HackerRankFind the number of unordered anagramic pairs of substrings of a string.www.hackerrank.com 풀이array 안의 모든 anagram의 pair 의 수를 구하는 문제이다.여기서 중요한 포인트는 #pair = (count * (count-1))..
문제https://www.hackerrank.com/challenges/crush/problem?h_l=interview&isFullScreen=true&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=arrays Array Manipulation | HackerRankPerform m operations on an array and print the maximum of the values.www.hackerrank.com 풀이각각의 query 마다 array를 업데이트하는 방법은 O(queries_rows * n) 이 걸려 n이 커질수록 너무 오래걸리게 된다.이 문제는 prefix sum을 사용한 문제로 우리가 필요한 것만 upd..
문제: https://www.hackerrank.com/challenges/minimum-swaps-2/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=arrays Minimum Swaps 2 | HackerRankReturn the minimum number of swaps to sort the given array.www.hackerrank.com 풀이:minimum swap (최적의 바꾸기)를 구하려면 cycle을 파악해야한다.여기서 cycle이란 index_before -> index_after가 계속 연결된 체인을 말한다. 예를 들어, arr = [4,..