- Today
- Total
목록스터디/코테 (223)
작심삼일
문제 링크: https://leetcode.com/problems/broken-calculator/ 문제 There is a broken calculator that has the integer startValue on its display initially. In one operation, you can: multiply the number on display by 2, or subtract 1 from the number on display. Given two integers startValue and target, return the minimum number of operations needed to display target on the calculator. 조건 1 startValue: ans..
문제 링크: https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/ 문제 The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on. The numeric value of a string consisting of lowercase characters is defined as the sum of its characters' numeric ..
문제 링크: https://leetcode.com/problems/partition-labels/ 문제 You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be s. Return a list of integers representing the size of these parts. 조건 1 0: ans.append(m..
문제 링크: https://leetcode.com/problems/remove-duplicate-letters/ 문제 Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. 조건 1 0 and ans[-1] > char and count[ord(ans[-1])-ord('a')] > 0: check[ord(ans[-1])-ord('a')] = False del ans[-1] ans.append(char) check[idx]..
문제 링크: https://leetcode.com/problems/score-of-parentheses/ 문제 Given a balanced parentheses string s, return the score of the string. The score of a balanced parentheses string is based on the following rule: "()" has score 1. AB has score A + B, where A and B are balanced parentheses strings. (A) has score 2 * A, where A is a balanced parentheses string. 조건 2
문제 링크: https://leetcode.com/problems/validate-stack-sequences/ 문제 Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise. 조건 1
문제 링크: https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/ 문제 Given a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string. Formally, a parentheses string is valid if and only if: It is the empty string, con..
문제 링크: https://leetcode.com/problems/simplify-path/ 문제 Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in a Unix-style file system, convert it to the simplified canonical path. In a Unix-style file system, a period '.' refers to the current directory, a double period '..' refers to the directory up a level, and any multiple consecutive slashes (i..