본문 바로가기

LeetCode16

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.
28. Implement strStr() c++ 28. Implement strStr() Easy 44483768Add to ListShare Implement strStr(). Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Clarification: What should we return when needle is an empty string? This is a great question to ask during an interview. For the purpose of this problem, we will return 0 when need.. 2022. 7. 7.
1. Two Sum Leetcode 문제 brute force 방식으로 풀었다. 어렵지 않게 이해할 수 있는 코드이다. class Solution { public: vector twoSum(vector& nums, int target) { vector v; for(int i = 0 ; i < nums.size() ; i++) { for(int j = i+1 ; j 2022. 7. 4.