본문 바로가기

분류 전체보기49

Bubble Sort 작동방식 (간단) _Bubble Sort 거품 정렬 또는 버블 정렬은 두 인접한 원소를 검사하여 정렬하는 방법이다. 시간 복잡도가 O(n^{2})로 상당히 느리지만, 코드가 단순하기 때문에 자주 사용된다. 원소의 이동이 거품이 수면으로 올라오는 듯한 모습을 보이기 때문에 지어진 이름이다 버블 솔트는 말 그대로 버블이라는 원 하나를 만들어 두개의 원소를 조사하여 더 작은 값을 큰 값이랑 스위치해 왼쪽으로 가게 만들어준다. Bubble Sort는 stable하다 (@@색은 버블이라 생각하면된다) [9, 3, 5, 7, 1] [9, 3, 5, 7, 1] --> [3, 9, 5, 7, 1] [3, 9, 5, 7, 1] --> [3, 5, 9, 7, 1] [3, 5, 9, 7, 1] --> [3, 5, 7, 9, 1] [3, 5,.. 2022. 7. 13.
415. Add Strings 문제 c++ 415. Add Strings Easy 3455574Add to ListShare Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly. 큰 정수(예: BigInteger)를 처리하기 위해 내장 라이브러리를 사용하지 않고 문제를 해결해야 합니다. 또한 입력.. 2022. 7. 10.
125. Valid Palindrome 문제 A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. 모든 대문자를 소문자로 변환하고 영숫자가 아닌 문자를 모두 제거한 후 앞뒤로 동일하게 읽는 경우 구는 회문입니다. 영숫자 문자에는 문자와 숫자가 포함됩니다. 문자열 s가 .. 2022. 7. 10.
796. Rotate String 문제 796. Rotate String Easy 194788Add to ListShare Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost position. For example, if s = "abcde", then it will be "bcdea" after one shift. Example 1: Input: s = "abcde", goal = "cdeab" Output: true Example 2: Input: s = "abc.. 2022. 7. 7.