Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Блог пользователя peroooo

Автор peroooo, 3 года назад, По-английски

Question 1:- You are given a string of numbers, You have to return a partitioned String Array in which substring (i-1)th +(i-2)th = ith substring. If not possible return an empty string array. For example: Input: Output: "111122335" ------> {"1","11","12","23","35"}
Input: Output: "112233" -------> {"11","22","33"} Input: Output: "11314" -------> {"11","3","14"} or {"1","13","14"} Input: Output: "13234113" -------->{}

Link:- https://www.geeksforgeeks.org/partition-given-string-manner-ith-substring-sum-1th-2th-substring/

So I gave a Backtracking solution(same as the given link) for the first question. but he asked me to improve the time complexity for the solution is there any better approach to solve this problem really can't think of anything else than backtracking.

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится