FastPrepCount Sunk and Damaged Battleships (Practice Reconstruction)
Problems/Count Sunk and Damaged Battleships (Practice Reconstruction)

Count Sunk and Damaged Battleships (Practice Reconstruction)

Marshall Wace logoMarshall Wace● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report verifies the Battleship task name, but its exact original statement is unavailable. This practice reconstruction uses rectangular ships and sunk/damaged counts from an author-linked reference, with explicit board and hit assumptions; it matches at about 60%.

For this exercise, assume an N by N board with rows numbered 1 through N and columns labeled A onward. A coordinate such as 12B means row 12, column B.

Each ship fills a rectangle whose sides follow the board’s rows and columns, including all boundary cells. Ships do not overlap. The string S lists the ships, separated by commas. Each ship is given by its top-left and bottom-right coordinates, separated by one space. An empty string means there are no ships.

String T lists hit coordinates separated by spaces; it may be empty. For this exercise, assume repeated hits on the same cell count only once, and hits on water have no effect.

Classify each ship as follows:

  • Sunk: every cell has been hit.
  • Damaged: at least one cell has been hit, but some have not.
  • Untouched: no cells have been hit.

Return the string sunken,damaged, containing those two ship counts separated by one comma and no spaces.

Function

solution(N: int, S: String, T: String) → String

Examples

Example 1

N = 5S = "1A 2B,4D 5D"T = "1A 2B 4D 5D"return = "1,1"

This example sinks the two-cell ship at 4D..5D. The rectangle 1A..2B has two of its four cells hit, so one ship is damaged.

Example 2

N = 3S = "1A 1A"T = "1A 1A"return = "1,0"

This example hits the same cell twice. Its one-cell ship is sunk once; repeated hits do not create another ship.

Example 3

N = 4S = "2B 3C"T = "1A 4D"return = "0,0"

This example hits only water, leaving the ship untouched.

Constraints

  • For this exercise, assume 1 <= N <= 26.
  • All coordinates are valid board cells. Each ship entry gives top-left before bottom-right; all ship rectangles are disjoint.
  • For this exercise, assume there are at most 10000 hit records.
  • Coordinate rows use decimal digits without leading zeros; columns use one uppercase English letter. Nonempty ship/hit entries use the separators described above.

More Marshall Wace Online Assessment questions

  • Count Letters with Ordered Lowercase and Uppercase OccurrencesOA · Seen Oct 2025
  • Maximum Trailing Zeros on a Path with at Most One TurnOA · Seen Oct 2025
  • Shortest Subarray Covering an Integer RangeOA · Seen Oct 2025
  • Maximum Events in a 60-Second WindowOA · Seen Aug 2025
  • Successful Logins from Multiple CountriesOA · Seen Aug 2025
  • Maximize Remaining Item Types After Clearing Consecutive ShelvesOA · Seen Nov 2024
  • Shortest String After Erasing Equal PairsOA · Seen Nov 2024
  • Count Distinct Tags in a Fixed-Radius Circle (Practice Reconstruction)OA · Seen Apr 2024
  • Generate Unique Company Email AddressesOA · Seen Apr 2024
  • Reconstruct a Two-Row Binary MatrixOA · Seen Apr 2024

Similar questions at other companies

  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Process Banking OperationsVercel · OA
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Count House Segments After Sequential DestructionByteDance · OAByteDance interview questions
  • HTTP Request RedirectionAmazon · OA
  • Hungarian Lottery Winner CountsAlpaca · OA
  • Cheating CodemakerJane Street · OAJane Street interview questions
  • Aggregate Paginated Project Run RecordsReplit · OA
  • Maximum Satisfied CustomersAtlassian · OAAtlassian interview questions
  • Occupy and Clean Memory by Allocation IDZipRecruiter · OAZipRecruiter interview questions

Interview reports that mention this question

  • Marshall Wace Older Quant Tests: 5 Experiences (Part 3 of 3)
  • Marshall Wace Quant and Coding OA: 19 Experiences (Part 1 of 3)

Marshall Wace interview experiences

  • Marshall Wace Coding Tests: 11 Experiences (Part 2 of 3)
All Marshall Wace interview questionsSee Marshall Wace hiring insights
Saved
class Solution {
    public String solution(int N, String S, String T) {
        // Write your solution here.
    }
}
Checking account…