Tap here to switch tabs
Problem
Submissions

Problem: Longest Binary Subsequence Less Than or Equal to K

med
30 min
Try to solve the Longest Binary Subsequence Less Than or Equal to K problem.

Statement

Given a binary string s and a positive integer k, return the length of the longest subsequence of s that represents a binary number less than or equal to k.

Note: The subsequence may contain leading zeros.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • s[i] is either '0' or '1'

  • 1≤1 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Binary Subsequence Less Than or Equal to K

med
30 min
Try to solve the Longest Binary Subsequence Less Than or Equal to K problem.

Statement

Given a binary string s and a positive integer k, return the length of the longest subsequence of s that represents a binary number less than or equal to k.

Note: The subsequence may contain leading zeros.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • s[i] is either '0' or '1'

  • 1≤1 \leq k ≤109\leq 10^9