Learn By Coding

Be a better programmer

Menu

Skip to content
  • Home

Daily Archives: December 28, 2014

count number of substrings that start and end with 1

Posted on December 28, 2014 by anirban0328

For example, if the input string is “00100101”, then there are three substrings “1001”, “100101” and “101”.

Ans

a) Count the number of 1’s. Let the count of 1’s be m.
b) Return m(m-1)/2

Posted in Algorithms | Leave a comment

Apti

Posted on December 28, 2014 by anirban0328
               1 
             1   1
             2   1
          1  2   1   1
       1  1  1   2   2   1

What is the next line?

Answer

LZ algorithm

Next line is pairs (count, digit) for sequence of digits in previous line.

3 1 2 2 1 1
Posted in Uncategorized | Leave a comment

Archives

Categories

Follow Learn By Coding on WordPress.com
December 2014
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Nov   Jan »
Blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Subscribe Subscribed
    • Learn By Coding
    • Already have a WordPress.com account? Log in now.
    • Learn By Coding
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
Design a site like this with WordPress.com
Get started