12 time complexity: 12687