문제
무차별 접근 방식:
TC: O(N^2), SC: O(256) 이는 상수입니다
참고: 이는 TLE로 이어질 것입니다
class Solution { public String minWindow(String s, String t) { int min = Integer.MAX_VALUE; int start =-1; int end = -1; //generating all possible substrings and returning the smallest substring having //all the character of string t for(int i =0;i<s.length int arr new all the asci characters with count of character in t for k="0;k<t.length();k++){" j="i;j<s.length();j++){" if at s is also present increase>0){ count++; } arr[s.charAt(j)]--;//decrease the frequency of s.charAt(j) by 1 in arr if(count ==t.length()){// if count == length of t we have found one potential substring if(min> j-i+1){ min = j-i +1; start = i; end = j; } break;// break out as there is no need to propagate further in the current iteration } } } if(start ==-1 || end ==-1) return "";// if not found return s.substring(start,end+1);// else } } </s.length>
최적 접근 방식:
TC: O(n) , SC:O(256) 는 상수입니다
// this intuition will require solving such problems as much as possible class Solution { public String minWindow(String s, String t) { int left=0,right=0; int min = Integer.MAX_VALUE; int count =0; int arr[] = new int[256]; // has table for keeping count of characters // keeping track of start and end index int start =-1; int end = -1; for(int i=0;i<t.length arr while char c="s.charAt(right);" if>0){ // if the character is part of t, then increment count count++; } arr[c]--;// decrease the count of the character in the hash table once it is taken into consideration while(count ==t.length()){ // if count == t.size() we have found a potential window if(min > right-left+1){ min = right-left+1; //update the start and end accordingly start = left; end = right; } arr[s.charAt(left)]++;//since we are removing this character from window and increasing the left pointer to point to next character after this, there will be one less //character that is not part of the t if(arr[s.charAt(left)]>0){ // if after doing +1 for arr[s.charAt(left)] character, if it become positive then it will mean that this was part of t, and now we will have to look for this character in the next window count--; // since this was part of t, then count should decrement by 1 } left++; } right++; } if(start ==-1 || end ==-1) return ""; return s.substring(start,end+1); } } </t.length>
위 내용은 최소 창 하위 문자열의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

이 기사에서는 Java 프로젝트 관리, 구축 자동화 및 종속성 해상도에 Maven 및 Gradle을 사용하여 접근 방식과 최적화 전략을 비교합니다.

이 기사에서는 Maven 및 Gradle과 같은 도구를 사용하여 적절한 버전 및 종속성 관리로 사용자 정의 Java 라이브러리 (JAR Files)를 작성하고 사용하는 것에 대해 설명합니다.

이 기사는 카페인 및 구아바 캐시를 사용하여 자바에서 다단계 캐싱을 구현하여 응용 프로그램 성능을 향상시키는 것에 대해 설명합니다. 구성 및 퇴거 정책 관리 Best Pra와 함께 설정, 통합 및 성능 이점을 다룹니다.

이 기사는 캐싱 및 게으른 하중과 같은 고급 기능을 사용하여 객체 관계 매핑에 JPA를 사용하는 것에 대해 설명합니다. 잠재적 인 함정을 강조하면서 성능을 최적화하기위한 설정, 엔티티 매핑 및 모범 사례를 다룹니다. [159 문자]

Java의 클래스 로딩에는 부트 스트랩, 확장 및 응용 프로그램 클래스 로더가있는 계층 적 시스템을 사용하여 클래스로드, 링크 및 초기화 클래스가 포함됩니다. 학부모 위임 모델은 핵심 클래스가 먼저로드되어 사용자 정의 클래스 LOA에 영향을 미치도록합니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

SecList
SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기
