Meta tags:
description= Special binary strings are binary strings with the following two properties: The number of 0's is equal to the number of 1's. Eve...;
keywords= leetcode, javascript, solutions, algorithms, data structures, coding, programming, coding challenges, coding problems, coding solutions;
author= LeetCodeJavascript.com;
Headings (most frequently used words):
761, special, binary, string, problem, description, solution,
Text of the page (most frequently used words):
string (11), the (11), binary (6), #special (5), return (4), let (3), count (3), start (3), specials (3), two (3), strings (3), are (3), leetcodejavascript (2), com (2), makelargestspecial (2), length (2), consecutive (2), character (2), first (2), number (2), view (2), github (2), leetcode (2), 761 (2), solutions (2), 2025, josh, crozier, param, function, const, for, push, slice, sort, reverse, join, solution, lexicographically, largest, resulting, possible, after, applying, mentioned, operations, move, consists, choosing, non, empty, substrings, and, swapping, them, last, exactly, one, index, before, second, you, given, every, prefix, has, least, many, equal, with, following, properties, problem, description, recursion, hard, back, all, star, javascript,
Text of the page (random words):
761 special binary string leetcode javascript solutions leetcodejavascript com star on github back to all solutions 761 special binary string hard view on leetcode view on github string recursion problem description special binary strings are binary strings with the following two properties the number of 0 s is equal to the number of 1 s every prefix of the binary string has at least as many 1 s as 0 s you are given a special binary string s a move consists of choosing two consecutive non empty special substrings of s and swapping them two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string return the lexicographically largest resulting string possible after applying the mentioned operations on the string solution param string s return string function makelargestspecial s if s length 2 return s let count 0 let start 0 const specials for let i 0 i s length i count s i 1 1 1 if count 0 specials push 1 makelargestspecial s slice start 1 i 0 start i 1 return specials sort reverse join 2025 leetcodejavascript com josh crozier
|