Flipkart
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2023-11-06Added By Anonymous
Source: Link
Company: Flipkart
Role: unknown
Stage: unknown
Location: unknown
Year: unknown
Original Post:
class Solution { public: bool winnerOfGame(string colors) { int countAAA = 0; int countBBB = 0; for (int i = 1; i + 1 < colors.length(); ++i) if (colors[i - 1] == colors[i] && colors[i] == colors[i + 1]) if (colors[i] == 'A') ++countAAA; else ++countBBB; return countAAA > countBBB; } };
Role: unknown
Stage: unknown
Location: unknown
Year: unknown
Original Post:
class Solution { public: bool winnerOfGame(string colors) { int countAAA = 0; int countBBB = 0; for (int i = 1; i + 1 < colors.length(); ++i) if (colors[i - 1] == colors[i] && colors[i] == colors[i + 1]) if (colors[i] == 'A') ++countAAA; else ++countBBB; return countAAA > countBBB; } };