본문 바로가기

Algorithm/Implementation

(751)
(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) 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 구현 문제였습니다. ..
(C++) - LeetCode (easy) 766. Toeplitz Matrix https://leetcode.com/problems/toeplitz-matrix/description/ Toeplitz Matrix - LeetCode Can you solve this real interview question? Toeplitz Matrix - Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. Example 1: leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 풀이과정 1. 화살표 방향으로 한 번씩 검사해서 ..
(C++) - LeetCode (easy) 762. Prime Number of Set Bits in Binary Representation https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/description/ Prime Number of Set Bits in Binary Representation - LeetCode Can you solve this real interview question? Prime Number of Set Bits in Binary Representation - Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binar..
(C++) - LeetCode (easy) 748. Shortest Completing Word https://leetcode.com/problems/shortest-completing-word/description/ Shortest Completing Word - LeetCode Can you solve this real interview question? Shortest Completing Word - Given a string licensePlate and an array of strings words, find the shortest completing word in words. A completing word is a word that contains all the letters in licensePlate. Ignore leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 풀이과정 ..
(C++) - LeetCode (easy) 747. Largest Number At Least Twice of Others https://leetcode.com/problems/largest-number-at-least-twice-of-others/description/ Largest Number At Least Twice of Others - LeetCode Can you solve this real interview question? Largest Number At Least Twice of Others - You are given an integer array nums where the largest integer is unique. Determine whether the largest element in the array is at least twice as much as every other numbe leetcod..
(C++) - LeetCode (easy) 728. Self Dividing Numbers.cpp https://leetcode.com/problems/self-dividing-numbers/description/ 📕 풀이방법 📔 입력 및 초기화 정답변수 ans를 선언해줍니다. 📔 풀이과정 1.left ~ right까지 for loop를 수행합니다. 2. 현재 원소를 문자열로 변환해 각 digit에 대해 for loop를 수행합니다. 3. 0이거나 나누어떨어지지 않는다면 loop를 탈출해줍니다. 📕 Code 📔 C++ class Solution { public: vector selfDividingNumbers(int left, int right) { vector ans; for(int i = left; i
(C++) - LeetCode (easy) 709. To Lower Case https://leetcode.com/problems/to-lower-case/description/