Tap here to switch tabs
Problem
Submissions

Problem: Count Beautiful Splits in an Array

med
30 min
Try to solve the Count Beautiful Splits in an Array problem.

Statement

You are given an integer array nums.

A split of the array nums into three non-empty contiguous subarrays nums1, nums2, and nums3 is called beautiful if their concatenation forms nums and at least one of the following conditions holds:

  • nums1 is a prefix of nums2.

  • nums2 is a prefix of nums3.

Return the total number of beautiful splits of nums.

Constraints:

  • 1≤1 \leq nums.length ≤5000\leq 5000

  • 0≤0 \leq nums[i] ≤50\leq 50

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Beautiful Splits in an Array

med
30 min
Try to solve the Count Beautiful Splits in an Array problem.

Statement

You are given an integer array nums.

A split of the array nums into three non-empty contiguous subarrays nums1, nums2, and nums3 is called beautiful if their concatenation forms nums and at least one of the following conditions holds:

  • nums1 is a prefix of nums2.

  • nums2 is a prefix of nums3.

Return the total number of beautiful splits of nums.

Constraints:

  • 1≤1 \leq nums.length ≤5000\leq 5000

  • 0≤0 \leq nums[i] ≤50\leq 50