본문 바로가기

전체 글

(2344)
(C++) - LeetCode (easy) 836. Rectangle Overlap https://leetcode.com/problems/rectangle-overlap/description/ Rectangle Overlap - LeetCode Can you solve this real interview question? Rectangle Overlap - An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top leetcode.com 분기문을 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1..
(C++) - LeetCode (easy) 832. Flipping an Image https://leetcode.com/problems/flipping-an-image/description/ Flipping an Image - LeetCode Can you solve this real interview question? Flipping an Image - Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. * F leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 풀이과정 요구사항 그대로 구현해줍..
(C++) - LeetCode (easy) 830. Positions of Large Groups https://leetcode.com/problems/positions-of-large-groups/description/ Positions of Large Groups - LeetCode Can you solve this real interview question? Positions of Large Groups - In a string s of lowercase letters, these letters form consecutive groups of the same character. For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", and leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 입력 ..
(C++) - LeetCode (easy) 824. Goat Latin https://leetcode.com/problems/goat-latin/description/ Goat Latin - LeetCode Can you solve this real interview question? Goat Latin - You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to "Goat Latin" (a made-up leetcode.com 문자열 다루는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 공백 문자 ' '를 구분자로..
(C++) - LeetCode (easy) 819. Most Common Word https://leetcode.com/problems/shortest-distance-to-a-character/description/ Shortest Distance to a Character - LeetCode Can you solve this real interview question? Shortest Distance to a Character - Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest leetcode.com 구현 문제였습니..
(C++) - LeetCode (easy) 819. Most Common Word https://leetcode.com/problems/most-common-word/description/ Most Common Word - LeetCode Can you solve this real interview question? Most Common Word - Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and tha leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 단어와 빈도수를 저장..
(C++) - LeetCode (easy) 812. Largest Triangle Area https://leetcode.com/problems/largest-triangle-area/description/ 📕 풀이방법 📔 입력 및 초기화 정답변수 maxArea 를 선언 후 0으로 초기화해줍니다. 📔 풀이과정 점 3개의 좌표를 알고 있다면 사선공식을 사용해 삼각형 면적을 구할 수 있으므로 3차원 for loop를 수행하며 최대 삼각형 면적을 구해 maxArea 📔 정답 출력 | 반환 maxArea를 반환합니다. 📕 Code 📔 C++ struct Point { int x,y; }; class Solution { public: double getTriangleArea(Point a, Point b, Point c){ return abs((a.x*b.y + b.x*c.y + c.x*a.y) - (..
(C++) - LeetCode (easy) 806. Number of Lines To Write String https://leetcode.com/problems/number-of-lines-to-write-string/description/ Number of Lines To Write String - LeetCode Can you solve this real interview question? Number of Lines To Write String - You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of leetcode.com 구현 문제였습니다. ..