물빠진떡 님의 블로그

  • 홈
  • 태그
  • 방명록

알고리즘 2

2024 10 27 1277. Count Square Submatrices with All Ones

문제Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.요약1만으로 체워진 사각형 갯수 찾기풀이누적합으로 풀면 쉬울것 같았다.행으로 누적합을 구한 매트릭스에서 다시 열로 다 더해서 누적합을 2*2 매트릭스를 만들면정사각형의 변 길이를 s라고 하였을때 [r][c],[r-s+1][c],[r][c-s+1],[r-s+1][c-s+1]이 만드는 사각형 내부의 값의 총 합은sum = prefix[r][c] - prefix[r-s][c] -prefix[r][c] + prefix[r-s][c-s]가 된다.코드class Solution { public int countSquares(int[][] matrix)..

알고리즘 2024.10.27

2024.10.22 LeetCode 1593. Split a String Into the Max Number of Unique Substrings

Given a string `s`, return _the maximum number of unique substrings that the given string can be split into_.You can split string `s` into any list of **non-empty substrings**, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are **unique**.A **substring** is a contiguous sequence of characters within a string.풀이 시간..

알고리즘 2024.10.22
이전
1
다음
더보기
프로필사진

물빠진떡 님의 블로그

물빠진떡을 싫어해서 물빠진떡입니다. 백엔드 개발자(진)입니다.

방문자수Total

  • Today :
  • Yesterday :
  • 분류 전체보기 (32)
    • 개발 (4)
    • 일기 (1)
    • 학습 (9)
    • 기술 할짝 (맛보기) (2)
    • 알고리즘 (15)

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

Copyright © Kakao Corp. All rights reserved.

티스토리툴바