Loading...

gcd와 xor의 성질, 연속하는 두 자연수는 서로소, dict보다 list를 먼저 고려하기

1. 문제 21004번: GCD vs. XOR (acmicpc.net) 21004번: GCD vs. XOR For each test case output a single integer: the number of pairs $(a_i, a_j)$ with $i y이면 p-q ..

2023. 8. 8. 03:06

문자열 해싱(hashing) 기본 개념 배우기

String Hashing - Algorithms for Competitive Programming (cp-algorithms.com) String Hashing - Algorithms for Competitive Programming String Hashing Hashing algorithms are helpful in solving a lot of problems. We want to solve the problem of comparing strings efficiently. The brute force way of doing so is just to compare the letters of both strings, which has a time complexity of $O(\mi cp-algori..

자바 자료구조4 -HashMap과 HashSet-

1. HashMap 해싱을 기반으로 데이터들을 관리해주는 자료구조 파이썬에서 dict와 대응된다 HashMap은 (key,value) 쌍 형태로 들어가 있어서, key와 그 key에 따른 value값을 동시에 저장하는 형태 따라서 HashMap의 삽입, 삭제, 탐색 등 모든 함수의 시간복잡도는 O(1)이다. HashMap은 TreeMap보다 속도가 빠르며, 값 자체에만 관심이 있지, 그 순서에는 관심이 없는 자료구조 HashMap 사용을 위해서 import java.util.HashMap; HashMap (name) = new HashMap(); 형태의 선언이 필요하다. K,V는 key와 value에 해당하는 타입이다. import java.util.HashMap; public class Main { p..