Brynn Park
close
프로필 배경
프로필 로고

Brynn Park

    • 분류 전체보기 (79)
      • Blockchain (10)
        • 마스터링 이더리움 (7)
        • 기본 개념 (1)
        • 개발 (2)
      • Algorithm (60)
        • LeetCode (19)
        • BOJ (33)
        • Programmers (6)
        • CodeTree (0)
      • SQL (1)
        • LeetCode (1)
      • 소프트웨어_개발 (3)
  • mode_edit_outline글작성
  • settings환경설정
  • 홈
  • 태그
  • 방명록
  • 카테고리
LeetCode 392. Is Subsequence

LeetCode 392. Is Subsequence

초기 접근 방법 ❗️처음에 생각한 방향 for 문을 중첩해서 배열을 하나하나 조회하고 계산해보려고 함 (brute force) Brute Force bool isSubsequence(char * s, char * t){ int s_len = strlen(s); int t_len = strlen(t); if(s_len>t_len) return false; if(!s_len) return true; int len=s_len; for(int i=0; i

  • format_list_bulleted Algorithm/LeetCode
  • · 2023. 8. 11.
  • textsms

LeetCode 238. Product of Array Except Self

초기 접근 방법 ❗️처음에 생각한 방향 for 문을 2번 돌리면 쉽게 해결되는 문제라고 생각함 answer에 대해 한 번, nums에 대해 한 번 돌려서 계산할 수 있지만 문제는 이렇게 했을 시, O(n^2)의 시간복잡도를 가지게 되어 문제 조건을 만족할 수 없음. int* productExceptSelf(int* nums, int numsSize, int* returnSize){ *returnSize = numsSize; int* answer = (int*) malloc((*returnSize)*sizeof(int)); int i, j; for(i=0; i

  • format_list_bulleted Algorithm/LeetCode
  • · 2023. 8. 11.
  • textsms

LeetCode 151. Reverse Words in a String

초기 접근 방법 ❗️처음에 생각한 방향 while(ptr != '\0') 로 단어를 구분하려고 했으나, 1. space가 여러개 삽입되는 경우, 맨 앞이 space로 시작하는 경우 예외가 생기고 2. 단어가 몇 개가 있는 지 모르기 때문에 break할 수 있는 조건이 애매함 따라서 생각한 방법은 strlen 을 통해 주어진 문자열의 길이를 파악한 뒤, for 문을 이용해 len만큼 반복문 돌리기 ➜ for(int i=0; i0; i--){ wordLen =0; if(s[i] != ' '){ while(s[i] != ' ' && i>=0){ wordLen++; i--; } index = i+1; for(;wordLen>0; wordLen--){ ret[j++]=s[index++]; } ret[j++]=' ..

  • format_list_bulleted 카테고리 없음
  • · 2023. 8. 11.
  • textsms

LeetCode 283. Move Zeroes

초기 접근 방법 ❗️처음에 생각한 방향 copy를 만들지 않고 주어진 배열 내에서 수행을 해야하므로 Bubble sort처럼 구현하여 정렬하려고 생각함 이렇게 하면 구현 자체는 간단하게 할 수 있음 (한 번 돌 때마다 가장 끝에는 0임을 확정짓는 것) 🚫 다만 이렇게 하면, 시간복잡도가 높아짐 ✏️ 그래서 생각한 방법 [i]와 [i+1] 번째 요소를 비교하며 0을 하나씩 뒤로 넘기는 Bubble sort보다는, Two Pointers, head와 tail index를 각각 두고, 0이 발견된 head index와 0이 아닌 tail index를 교환하는 방법을 생각 void moveZeroes(int* nums, int numsSize){ if(!numsSize) return; int head = 0; ..

  • format_list_bulleted Algorithm/LeetCode
  • · 2023. 8. 11.
  • textsms
LeetCode 1581. Customer Who Visited but Did Not Make Any Transactions

LeetCode 1581. Customer Who Visited but Did Not Make Any Transactions

구현 오류 # Write your MySQL query statement below select distinct v.customer_id, count(v.visit_id) as count_no_trans from Visits v where not exists ( select v.visit_id from Visits v, Transactions t where v.visit_id = t.visit_id ) group by v.customer_id; ❌ 이유 ❌ WHERE NOT EXISTS 에서 from Visits, Transactions 가 모두 들어간 것이 오류 💡 from에 여러개의 table을 넣으면 어떻게 될까? from 에 2개의 table을 넣게 되면, 2개의 Table이 그냥 Cartesia..

  • format_list_bulleted SQL/LeetCode
  • · 2023. 8. 10.
  • textsms
LeetCode 345. Reverse Vowels of a String

LeetCode 345. Reverse Vowels of a String

접근 오류 ❗️처음에 생각한 방향 처음에 생각한 방향이 오류없이 한 번에 구현되었음 따라서 접근 오류는 없음 히히 ! ✌️ 접근 ✅ string의 맨 앞에서 시작하는 포인터(head)와 맨 뒤에서 시작하는 포인터(tail)를 각각 둔 뒤, 포인터를 각자 방향으로 옮겨가며 둘 다 vowel인 경우 Swap할 것 ( 정확히 말하자면 포인터보다는 인덱스가 맞는 말 ) ✅ 모음인지 확인할 수 있는 함수는 switch 문을 사용해 따로 만들 것 - 이렇게 생각한 이유는, 문제 조건에 ASCII로 표현가능한 모든 문자라고 했기 때문에 대소문자 포함 10개이고, 10개 모두 동일하게 true가 반환되는 간단한 함수이므로 그냥 따로 빼서 계산하는 것이 편하다고 생각함 ✅ Loop의 조건을 무엇으로 할 것인가? 보통 h..

  • format_list_bulleted Algorithm/LeetCode
  • · 2023. 8. 10.
  • textsms
  • 1
  • 2
  • 3
  • 4
공지사항
전체 카테고리
  • 분류 전체보기 (79)
    • Blockchain (10)
      • 마스터링 이더리움 (7)
      • 기본 개념 (1)
      • 개발 (2)
    • Algorithm (60)
      • LeetCode (19)
      • BOJ (33)
      • Programmers (6)
      • CodeTree (0)
    • SQL (1)
      • LeetCode (1)
    • 소프트웨어_개발 (3)
최근 글
인기 글
최근 댓글
태그
  • #c
  • #Medium
  • #array
  • #BOJ
  • #DP
  • #Algorithm
  • #leetcode
  • #블록체인
  • #greedy
  • #웹3
전체 방문자
오늘
어제
전체
Copyright © 쭈미로운 생활 All rights reserved.
Designed by JJuum

티스토리툴바