public int clearRows() {
		int rowsCleared = 0;
		// YOUR CODE HERE
		int maxHeight = getMaxHeight();
		
		// according to assignment doc, normally, the clear row comes after place.
		if (committed)
			// if clearRows not invoke after place, we should do backup here.
			for (int i = 0; i < grid.length; i++) 
				System.arraycopy(grid[i], 0, grid_backup[i], 0, grid[i].length);
		committed = false;
		for (int toIndex = 0; toIndex <= maxHeight; toIndex++) {
			if (width == getRowWidth(toIndex)) {
				// full-filled
				int fromIndex = toIndex + 1;
				while (fromIndex <= maxHeight && width == getRowWidth(fromIndex))
					fromIndex++;
				// now do copy
				for (int i = 0; i < width; i++) {
					grid[i][toIndex] = grid[i][fromIndex];
					//  make the 'from' row empty
					grid[i][fromIndex] = false;
				}
				// shift the 'from' row up.
				int ceil = maxHeight-rowsCleared;
				while (fromIndex < ceil) {
					for (int i=0; i < width; i++) {
						grid[i][fromIndex] = grid[i][fromIndex+1];
						grid[i][fromIndex+1] = false;
					}
					fromIndex++;
				}
				rowsCleared++;
			}
		}

		sanityCheck();
		return rowsCleared;
	}