I have too many columns in the sheet and so many columns to hide as well, but while executing the script it runs half way and stopped saying maximum time reached.

When I again tried to execute it stopped exactly where I stopped previously. So I would like to have some customization that if the column is already hidden can skip that column and work on the others.

Is there any way to do it.

Here is the code I used:

```js
function hideColumns() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sh = ss.getSheetByName('ANALYTIC');
    var data = sh.getRange('6:6').getValues();
    var numCols = sh.getMaxColumns();
    var numRows = sh.getMaxRows();

    for(var i = 0; i <= numCols; i++){
        if(data[0][i] == ""){
            sh.hideColumns(i+1);
        } else {
            sh.unhideColumn(sh.getRange(1, i+1, numRows, 1));
        }
    }
}

```

Please help me.