Leetcode – Zuma Game

Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W). You also have several balls in your hand. Each time, you may choose a ball in your hand, and insert it into the row (including the leftmost place and rightmost place). Then, if there is […]

Read More

Number Complement – Leetcode

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero bit in the integer’s binary representation. Example 1:

Example 2:

  […]

Read More

Max Consecutive Ones – Leetcode

Given a binary array, find the maximum number of consecutive 1s in this array. Example 1:

Note: The input array will only contain 0 and 1. The length of input array is a positive integer and will not exceed 10,000   Solution This is an easy to solve problem. We keep on counting the ones till a […]

Read More

Construct the Rectangle Leetcode

Given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

You need to output the length L and the width W of the web page you designed in sequence. Example:

  Note: The given area […]

Read More

Binary Tree Paths

Problem Given a binary tree, return all root-to-leaf paths. Define a tree with left and right nodes

Create Binary Tree and print path

Read More