Posts

Showing posts with the label 面试模拟

1022. Valid Tic-Tac-Toe State

A Tic-Tac-Toe board is given as a string array  board . Return  true  if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game. The  board  is a 3 x 3 array, and consists of characters  ' ' ,  'X' , and  'O' . The  ' ' character represents an empty square. Here are the rules of Tic-Tac-Toe: Players take turns placing characters into empty squares  ' ' . The first player always places  'X'  characters, while the second player always places  'O'  characters. 'X'  and  'O'  characters are always placed into empty squares, never filled ones. The game ends when there are 3 of the same (non-empty) character filling any row, column, or diagonal. The game also ends if all squares are non-empty. No more moves can be played if the game is over. board  is a length-3 array of strings, where each string  board[i]  has length 3. ...

639. Word Abbreviation 典型的还原面试时大脑黑洞的场景

写着写着,写不下去了!!! Given an array of n distinct non-empty strings, you need to generate  minimal  possible abbreviations for every word following rules below. Begin with the first character and then the number of characters abbreviated, which followed by the last character. If there are any conflict, that is more than one words share the same abbreviation, a longer prefix is used instead of only the first character until making the map from word to abbreviation become unique. In other words, a final abbreviation cannot map to more than one original words. If the abbreviation doesn't make the word shorter, then keep it as original. Both n and the length of each word will not exceed 400. The length of each word is greater than 1. The words consist of lowercase English letters only. The return answers should be in the same order as the original array. Have you met this question in a real interview?    Yes Problem Correction Example ...