Problem 568. Number of 1s in a binary string
Find the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input string is '0000', the output is 0
Solution Stats
Problem Comments
-
3 Comments
Ryan McBurney
on 30 Aug 2019
Something weird is happening
When I submit the size of my code is -1 and it fails the test suite when it seems to work fine in MATLAB desktop.
Fakhteh Ghalami
on 9 Nov 2019
would you please let me know why
sum(x) creates error?
Devon Chen
on 10 Nov 2021
Cool problem!
Solution Comments
Show commentsGroup

Strings I
- 30 Problems
- 102 Finishers
- Guess Cipher
- QWERTY Shift Encoder
- Calculate a modified Levenshtein distance between two strings
- Find matching string from a list of strings
- Find matching parenthesis
- Transposition as a CIPHER
- Decimal Comparison
- Return the first and last characters of a character array
- Find Rotated Substring
- Cell Counting: How Many Draws?
- Split a string into chunks of specified length
- Ordinal numbers
- Add more zeros
- Without the French accent please!
- Calculate a modified Levenshtein distance between two strings
- Calculate the Hamming distance between two strings
- Find mistyped words in text (mixed-up letters)
- QWERTY Shift Code Decoder
- QWERTY Shift Encoder
- Convert a structure into a string
- Return the first and last characters of a character array
- String substitution, sub problem to cryptoMath
- Number of 1s in a binary string
- Transposition as a CIPHER
- Use of regexp
- Pig Latin to English Translator
- English to Pig Latin Translator
- Formatting currency numbers
- Bang Bang in Bangalore
- Compress strings (not springs)
- letter yes yes & letter no no
- Convert String to Morse Code
- Decimal Comparison
- Find matching string from a list of strings
- Find Rotated Substring
- Reverse the Words (not letters) of a String
- Space Saver
- Find matching parenthesis
Problem Recent Solvers9727
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!