1016. Binary String With Substrings Representing 1 To N Medium

@problem@discussion
#String



1/**
2 * [1016] Binary String With Substrings Representing 1 To N
3 *
4 * Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or false otherwise.
5 * A substring is a contiguous sequence of characters within a string.
6 *  
7 * Example 1:
8 * Input: s = "0110", n = 3
9 * Output: true
10 * Example 2:
11 * Input: s = "0110", n = 4
12 * Output: false
13 *  
14 * Constraints:
15 * 
16 * 	1 <= s.length <= 1000
17 * 	s[i] is either '0' or '1'.
18 * 	1 <= n <= 10^9
19 * 
20 */
21pub struct Solution {}
22
23// problem: https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/
24// discuss: https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/discuss/?currentPage=1&orderBy=most_votes&query=
25
26// submission codes start here
27
28impl Solution {
29    pub fn query_string(s: String, n: i32) -> bool {
30        false
31    }
32}
33
34// submission codes end
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39
40    #[test]
41    fn test_1016() {
42    }
43}
44


Back
© 2025 bowen.ge All Rights Reserved.