본문 바로가기

LeetCode342

leetcode 197. Rising Temperature 1 2 3 4 5 /* Write your PL/SQL query statement below */ select t1.id as id from Weather t1,Weather t2 where (t1.recordDate-t2.recordDate)=1 and t1.temperature>t2.temperature cs 2022. 3. 17.
leetcode 183. Customers Who Never Order 1 2 3 4 5 /* Write your PL/SQL query statement below */ select c.name as customers from customers c, orders o where c.id=o.customerId(+) and o.customerId is null cs 2022. 3. 17.
leetcode 182. Duplicate Emails 1 2 3 4 5 /* Write your PL/SQL query statement below */ select email from person group by email having count(email)>1 cs 2022. 3. 17.
leetcode 181. Employees Earning More Than Their Managers 1 2 3 4 5 /* Write your PL/SQL query statement below */ select e1.name as employee from employee e1, employee e2 where e1.managerId=e2.id and e1.salary>e2.salary cs 2022. 3. 17.
leetcode 175. Combine Two TablesEasy 1 2 3 4 5 6 7 /* Write your PL/SQL query statement below */ select p.firstname,p.lastname,a.city,a.state from person p, address a where p.personid=a.personid(+) cs 2022. 3. 17.
leetcode 290. Word Pattern 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 class Solution: def wordPattern(self, pattern: str, s: str) -> bool: s=list(s.split()) checkList=[] checkPattern=[] ans='' ansPattern='' for i in s: if i in checkList : pass else: checkList.append(i) ans += chr(checkList.index(i) + 97) for i in pattern: if i in checkPattern : pass else: checkPattern.append(i) ansPattern += chr(checkPattern.in.. 2022. 3. 17.
leetcode 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence 1 2 3 4 5 6 7 8 9 class Solution: def isPrefixOfWord(self, sentence: str, searchWord: str) -> int: sentence=list(sentence.split()) searchWordLength=len(searchWord) index=-1 for i in sentence: if len(i)>=len(searchWord): if i[:searchWordLength]==searchWord : index=sentence.index(i)+1;break return (index) Colored by Color Scripter cs 2022. 3. 17.
leetcode 2185. Counting Words With a Given Prefix 1 2 3 4 5 6 7 class Solution: def prefixCount(self, words: List[str], pref: str) -> int: prefLength=len(pref) cnt=0 for i in words: if i[:prefLength]==pref : cnt+=1 return cnt Colored by Color Scripter cs 2022. 3. 17.
leetcode 595. Big Countries 1 2 3 4 5 /* Write your PL/SQL query statement below */ select name, population, area from world where area>=3000000 or population>=25000000 cs 2022. 3. 17.
leetcode 557. Reverse Words in a String III 1 2 3 4 5 6 7 class Solution: def reverseWords(self, s: str) -> str: s=list(s.split()) ans='' for i in s: ans+=i[::-1]+' ' return ans[:-1] cs 2022. 3. 17.
leetcode 2000. Reverse Prefix of Word 1 2 3 4 5 6 7 8 9 class Solution: def reversePrefix(self, word: str, ch: str) -> str: try: that=word.index(ch) word=word[:that+1][::-1]+word[word.index(ch)+1:] #return newWord except : #return word pass return word Colored by Color Scripter cs 2022. 3. 16.
leetcode 1704. Determine if String Halves Are Alike 1 2 3 4 5 6 7 8 9 10 11 12 13 class Solution: def halvesAreAlike(self, s: str) -> bool: vowel=['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] half1=s[:len(s)//2] half2=s[len(s)//2:] half1Cnt=0 for i in half1: if i in vowel: half1Cnt+=1 half2Cnt=0 for i in half2: if i in vowel: half2Cnt+=1 if half1Cnt==half2Cnt : return True else: return False Colored by Color Scripter cs 2022. 3. 16.