FastPrepCount Connect-Four Scoring Lines
Problems/Count Connect-Four Scoring Lines

Count Connect-Four Scoring Lines

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bloomberg new grad phone screen. The report gives a grid of characters, Connect Four scoring, all horizontal, vertical, and diagonal directions, and a count as the output. It leaves out what an empty cell looks like and how overlaps count. Here empty cells are dots, and each different window of four cells counts once. Our version is about 92% the same as the reported question.

Given a rectangular board grid, return the number of scoring lines on it. The board is never empty. A dot (.) is an empty cell, and each uppercase English letter is one piece type.

A scoring line is four cells next to each other in one straight line, all holding the same letter. The line can run horizontally, vertically, diagonally down-right, or diagonally down-left. Each set of four cells counts once. Overlapping sets count separately, so five equal letters in a straight run give two scoring lines.

The board may not match a real game with gravity or a move history. You do not need to check that.

Function

countScoringLines(grid: String[]) → int

Examples

Example 1

grid = [".......",".......",".......",".......","AAAA...","BBBB..."]return = 2
grid
01234560.......1.......2.......3.......4AAAA...5BBBB...

The row AAAA... and the row BBBB... each hold one horizontal line of four. There are no other lines, so the answer is two.

Example 2

grid = ["AAAAA"]return = 2
grid
012340AAAAA

The five A cells hold two overlapping lines of four: one starts at column 0 and one starts at column 1. So the answer is two.

Example 3

grid = ["X..Y..Z","X.Y...Z","XY....Z","Y.....Z"]return = 2
grid
01234560X..Y..Z1X.Y...Z2XY....Z3Y.....Z

The Y cells run diagonally down-left from the top row to the bottom-left corner, and the Z cells fill the last column. The X cells stop after three, so the answer is two.

Constraints

  • 1 <= grid.length <= 1000.
  • 1 <= grid[r].length <= 1000.
  • Every row has the same length, and the board has at most 200000 cells.
  • Every cell is . or an uppercase English letter.

More Bloomberg LP Phone Screen questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
  • Trace an Eight-Direction Robot Until BlockedPinterest · PHONE SCREENPinterest interview questions
  • Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions
  • Mark a Queen’s Attack BoardMotive · PHONE SCREENMotive interview questions
  • Spiral Order with ObstaclesTemu · PHONE SCREENTemu interview questions
  • Incremental Hard Attention with a KV CacheOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Spiral Matrix TraversalByteDance · PHONE SCREENByteDance interview questions
  • S-Shaped Matrix TraversalFox Corporation · PHONE SCREEN
  • Zigzag Board Adjacent SwapsUber · PHONE SCREENUber interview questions
  • Longest Consecutive Same-Color LineGoogle · PHONE SCREENGoogle interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad VOs: 32 Experiences (Part 5 of 5)
  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int countScoringLines(String[] grid) {
        // Write your code here.
    }

}
Checking account…