Skip to content

Commit

Permalink
- fixing problems
Browse files Browse the repository at this point in the history
- fix description for chocolate bars
  • Loading branch information
spolnik committed Feb 10, 2017
1 parent 8838813 commit f2597ee
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
Binary file modified ProblemsStore/00000000000.xd
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/versioning.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//noinspection GroovyAssignabilityCheck
version = new ProjectVersion(
'1', '0', '27', System.env.TRAVIS_BUILD_NUMBER
'1', '0', '28', System.env.TRAVIS_BUILD_NUMBER
)

println "Version number: " + version
Expand Down
2 changes: 1 addition & 1 deletion problems.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{"id":"find-max","title":"Find Max Element","description":"Given a binary tree, write a method `findMax` to return maximum element. Return 0 for empty tree.\r\n\r\n### Example\r\n\r\n ``` \r\n 20 \r\n / \\ \r\n 15 30 \r\n / \\ \r\n14 18 \r\n \r\noutput ==> 30\r\n\r\n```","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"findMax","returnStatement":{"type":"java.lang.Integer","comment":" Max element of a binary tree"},"parameters":[{"name":"root","type":"com.jalgoarena.type.TreeNode","comment":"Root of binary tree"}]},"testCases":[{"input":[{"data":5,"left":{"data":3,"left":{"data":2},"right":{"data":4}},"right":{"data":8,"left":{"data":6},"right":{"data":9}}}],"output":9},{"input":[{"data":1,"left":{"data":2,"left":{"data":4},"right":{"data":5}},"right":{"data":3,"left":{"data":10},"right":{"data":7}}}],"output":10},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}}],"output":7},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":40}}}}],"output":40},{"input":[{"data":20,"left":{"data":15,"left":{"data":10},"right":{"data":30}},"right":{"data":40}}],"output":40},{"input":[{"data":50,"left":{"data":15,"left":{"data":10},"right":{"data":16}},"right":{"data":40}}],"output":50},{"input":[{"data":1}],"output":1},{"input":[null],"output":0}]},
{"id":"is-cyclic","title":"Is List cyclic","description":"Given a singly linked list, write a method `isCyclic` to check if the list has cycles. The space complexity can be O(n). If there is a cycle, return true otherwise return false. Empty lists should be considered non-cyclic.\r\n\r\n### Examples\r\n\r\n* `1->2->3->4->5->6->1` -> `true`","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"isCyclic","returnStatement":{"type":"java.lang.Boolean","comment":" Is List cyclic"},"parameters":[{"name":"head","type":"com.jalgoarena.type.ListNode","comment":"Input list"}]},"testCases":[{"input":[[1,2,3,4,5,6]],"output":false},{"input":[[1,2,3,4,5,6,6]],"output":true},{"input":[[1,2,3,4,5,6,1]],"output":true},{"input":[[1,2,3,4,5,3,6]],"output":true},{"input":[[1]],"output":false},{"input":[[1,2]],"output":false},{"input":[[2,2]],"output":true},{"input":[null],"output":false}]},
{"id":"max-sum-path","title":"Maximum sum path","description":"Given a binary tree, write a method `maxSumPath` that returns the maximum sum of data values obtained by traversing nodes along a path between any 2 nodes of the tree. The path must originate and terminate at 2 different nodes of the tree, and the maximum sum is obtained by summing all the data values of the nodes traversed along this path..\r\n\r\n### Example\r\n\r\n ``` \r\n 1 \r\n / \\ \r\n 2 3 => 18 \r\n / \\ / \\ \r\n 4 5 6 7 \r\n \r\nPath: 5 -> 2 -> 1 -> 3 -> 7 \r\nMax Sum = 5+2+1+3+7 = 18 \r\n```","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"maxSumPath","returnStatement":{"type":"java.lang.Integer","comment":" Sum of all elements in max path"},"parameters":[{"name":"root","type":"com.jalgoarena.type.TreeNode","comment":"Root of binary tree"}]},"testCases":[{"input":[{"data":1,"left":{"data":2,"left":{"data":4},"right":{"data":5}},"right":{"data":3,"left":{"data":6},"right":{"data":7}}}],"output":18},{"input":[{"data":1,"left":{"data":2,"left":{"data":4,"left":{"data":8},"right":{"data":9}},"right":{"data":5}},"right":{"data":3,"left":{"data":6},"right":{"data":7}}}],"output":26},{"input":[{"data":1,"left":{"data":2,"left":{"data":4},"right":{"data":-5}},"right":{"data":3,"left":{"data":6},"right":{"data":-7}}}],"output":16},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}}],"output":23},{"input":[{"data":1}],"output":1},{"input":[null],"output":0}]},
{"id":"chocolate-bars","title":"Chocolate Bars","description":"A rectangular chocolate bar is divided into squares by horizontal and vertical grooves, in the usual way. It is to be cut into individual squares. A cut is made by choosing a piece and cutting along one of it grooves. (Thus each cut splits one piece into at least two pieces). Additionally, your chocolate is already cut into two pieces. Write a method `countChocolateCuts` with a number answering question - what is the minimal number of cuts needed to completely cut the two parts of chocolate into all its squares?\n\n### Note\n* like in example below, the groove is calculated as 1 only when all the squares are connected. Every space between squares creates a new groove.\n\n### Examples\n\n``` \n [1] \n [1][1][1] \n [1]\n & ==> 9 \n[1][1][1] \n [1] \n[1][1][1]\n\nExplanation: \n [1] | |\n-----|---|---\n [1] |[1]|[1] => 4\n-----|---|---\n [1] | |\n & ==> 4 + 5 = 9\n[1]|[1]|[1] \n---|---|----\n |[1] => 5\n---|---|----\n[1]|[1]|[1]\n```","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"countChocolateCuts","returnStatement":{"type":"java.lang.Integer","comment":" Number of cuts"},"parameters":[{"name":"chocolateBarPartOne","type":"[[I","comment":"Matrix representing first part of chocolate bar"},{"name":"chocolateBarPartTwo","type":"[[I","comment":"Matrix representing second part of chocolate bar"}]},"testCases":[{"input":[[[1],[1,1,1],[1]],[[1,1,1],[1],[1,1,1]]],"output":9},{"input":[[[1,1,1,1],[1],[1,1,1],[1,1]],[[1,1,1],[1],[1,1]]],"output":11},{"input":[[[]],[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]]],"output":15},{"input":[[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]]],"output":30},{"input":[[[1]],[[1]]],"output":0},{"input":[[[0,0],[0,0]],[[0,0],[0,0]]],"output":6},{"input":[[[]],[[]]],"output":0}]},
{"id":"chocolate-bars","title":"Chocolate Bars","description":"A rectangular chocolate bar is divided into squares by horizontal and vertical grooves, in the usual way. It is to be cut into individual squares. A cut is made by choosing a piece and cutting along one of it grooves. (Thus each cut splits one piece into at least two pieces). Additionally, your chocolate is already cut into two pieces. Write a method `countChocolateCuts` with a number answering question - what is the minimal number of cuts needed to completely cut the two parts of chocolate into all its squares?\n\n### Note\n* like in example below, the groove is calculated as 1 only when all the squares are connected. Every space between squares creates a new groove.\n\n### Examples\n\n``` \n [1] \n [1][1][1] \n [1]\n & ==> 9 \n[1][1][1] \n [1] \n[1][1][1]\n\nExplanation: \n [1] | |\n-----|---|---\n [1] |[1]|[1] => 4\n-----|---|---\n [1] | |\n & ==> 4 + 5 = 9\n[1]|[1]|[1] \n---|---|----\n |[1] => 5\n---|---|----\n[1]|[1]|[1]\n```","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"countChocolateCuts","returnStatement":{"type":"java.lang.Integer","comment":" Number of cuts"},"parameters":[{"name":"chocolateBarPartOne","type":"[[I","comment":"Matrix representing first part of chocolate bar"},{"name":"chocolateBarPartTwo","type":"[[I","comment":"Matrix representing second part of chocolate bar"}]},"testCases":[{"input":[[[1],[1,1,1],[1]],[[1,1,1],[1],[1,1,1]]],"output":9},{"input":[[[1,1,1,1],[1],[1,1,1],[1,1]],[[1,1,1],[1],[1,1]]],"output":12},{"input":[[[]],[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]]],"output":15},{"input":[[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]]],"output":30},{"input":[[[1]],[[1]]],"output":0},{"input":[[[0,0],[0,0]],[[0,0],[0,0]]],"output":6},{"input":[[[]],[[]]],"output":0}]},
{"id":"insert-stars","title":"Insert Stars","description":"Given a string, write a method `insertPairStar` to compute a new string where the identical adjacent characters in the original string are separated by a \"*\".\r\n\r\n### Example\r\n\r\n* `'sas` -> `'sas'`\r\n* `'kk` -> `'k*k'`","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"insertPairStar","returnStatement":{"type":"java.lang.String","comment":" Computed string"},"parameters":[{"name":"str","type":"java.lang.String","comment":"Input string"}]},"testCases":[{"input":["asdsdakz"],"output":"asdsdakz"},{"input":["aaaaa"],"output":"a*a*a*a*a"},{"input":["kk"],"output":"k*k"},{"input":["kkcckkcc"],"output":"k*kc*ck*kc*c"},{"input":[""],"output":""},{"input":[null],"output":null}]},
{"id":"decompress-tree","title":"Tree Decompression","description":"Given a binary tree, write a method `decompressTree` that decompresses that tree (reconstructs the tree) and returns the root TreeNode. The compression algorithm included traversing the tree level by level, from the left to the right. The TreeNode's data values were appended to the String, delimited by commas. Also, null TreeNodes were denoted by appending an asterisk - *. The input String denotes the structure of a Full Binary Tree - i.e. a tree that is structurally balanced. However, the reconstructed tree may not be a full tree as the String included * characters, which represent null TreeNodes\r\n\r\n###Note\r\n\r\n You can assume that if a Binary Tree contains k levels, the compressed String will contain 2^k-1 elements - either numbers or *.\r\n\r\n### Example\r\n\r\n ```\r\n 1\r\n / \\\r\n 2 3 ==> Compressed String = '1,2,3,4,5,6,7'\r\n / \\ / \\\r\n 4 5 6 7 \r\n```","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"decompressTree","returnStatement":{"type":"com.jalgoarena.type.TreeNode","comment":" Decompressed binary tree"},"parameters":[{"name":"root","type":"java.lang.String","comment":"Compressed Tree"}]},"testCases":[{"input":["1,2,3,4,5,6,7"],"output":{"data":1,"left":{"data":2,"left":{"data":4},"right":{"data":5}},"right":{"data":3,"left":{"data":6},"right":{"data":7}}}},{"input":["1,2,3,4,*,*,7"],"output":{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7}}}},{"input":["1"],"output":{"data":1}},{"input":["1,*,2,*,*,*,3"],"output":{"data":1,"right":{"data":2,"right":{"data":3}}}},{"input":[null],"output":null},{"input":["*"],"output":null},{"input":[""],"output":null}]},
{"id":"check-perm","title":"Check Permutations","description":"Given two strings, write a method `permutation` to decide if one is a permutation of other.\r\n\r\n### Examples\r\n\r\n* `\"abc\", \"cba\"` -> `true`\r\n* `\"abc\", \"cb\"` -> `false`","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"permutation","returnStatement":{"type":"java.lang.Boolean","comment":" Indicate if one string is a permutation of another"},"parameters":[{"name":"str1","type":"java.lang.String","comment":"first string to be checked for permutation match"},{"name":"str2","type":"java.lang.String","comment":"second string to be checked for permutation match"}]},"testCases":[{"input":["abc","cba"],"output":true},{"input":["abc","cbacba"],"output":false},{"input":["abccba","cbaccb"],"output":false},{"input":["abc","cbad"],"output":false},{"input":["AdSda","dAdaS"],"output":true},{"input":["AbcdefgHA",""],"output":false},{"input":["",""],"output":true},{"input":[" "," "],"output":false},{"input":["A","A"],"output":true},{"input":["A","a"],"output":false},{"input":[" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~","0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !\"#$%&'()*+,-./"],"output":true},{"input":[" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~a","0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],"output":false}]},
Expand Down

0 comments on commit f2597ee

Please sign in to comment.