Skip to content

Commit 78f4c14

Browse files
committed
- new problems
- factorial - country postman
1 parent 82e930d commit 78f4c14

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

ProblemsStore/00000000000.xd

30.5 KB
Binary file not shown.

gradle/versioning.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//noinspection GroovyAssignabilityCheck
22
version = new ProjectVersion(
3-
'1', '0', '23', System.env.TRAVIS_BUILD_NUMBER
3+
'1', '0', '24', System.env.TRAVIS_BUILD_NUMBER
44
)
55

66
println "Version number: " + version

problems.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@
7070
{"id":"largest-square","title":"Largest Square","description":"Given a two dimensional matrix made up of **0**'s and **1**'s, write a method `largestSquare` to find the largest square containing all 1's and return its `area`. \n\nThe `area` is simply the sum of all integers enclosed in the square.\n\n### Example\n\n```\nInput Matrix : \n \n 1101 xxxx 11xx\n 1101 => 11xx or 11xx\n 1111 11xx xxxx\n\nOutput : 4\n```","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"largestSquare","returnStatement":{"type":"java.lang.Integer","comment":"Area of the largest square"},"parameters":[{"name":"matrix","type":"[[C","comment":"2D matrix of 0s and 1s"}]},"testCases":[{"input":[[["1","1","0","1"],["1","1","0","1"],["1","1","1","1"]]],"output":4},{"input":[[["1","1"],["1","1"]]],"output":4},{"input":[[["1","1","1"],["1","1","1"],["1","1","1"]]],"output":9},{"input":[[["1","0"],["0","1"]]],"output":1},{"input":[[["1","1","0","1","0"],["1","1","0","1","1"],["0","1","1","1","0"],["1","1","1","1","1"],["1","1","1","1","0"]]],"output":9},{"input":[[["0","0"],["0","0"]]],"output":0}]},
7171
{"id":"longest-palindromic-substring","title":"Longest Palindromic Substring","description":"Given a `String`, write the method `longestPalSubstr` that finds and returns the longest substring which is also a `Palindrome`. \n\nTry and accomplish this in at most **O(n^2)** runtime.\n\n### Examples\n\n* `\"bccb\"` => `\"bccb\"`\n* `\"bccd\"` => `\"cc\"`\n* `\"bccc\"` => `\"ccc\"`","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"longestPalSubstr","returnStatement":{"type":"java.lang.String","comment":"Longest substring which is also a Palindrome"},"parameters":[{"name":"str","type":"java.lang.String","comment":"input"}]},"testCases":[{"input":["bccb"],"output":"bccb"},{"input":["bccd"],"output":"cc"},{"input":["bccc"],"output":"ccc"},{"input":["AAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBAAAAAAAAAAAAAAACCCCCCCDDDAAAAAAAAAAAAAAAA"],"output":"AAAAAAAAAAAAAAABBBBBBBBBBBBBBAAAAAAAAAAAAAAA"},{"input":["A"],"output":"A"},{"input":["ABCD"],"output":"A"},{"input":["ABCDEFGHHGFEBA"],"output":"EFGHHGFE"}]},
7272
{"id":"1-800-problem","title":"1-800-Problem","description":"Given a `String` that represents the digits pressed on a classic cell phone keypad - return all possible letter `combinations` that the numbers could represent in an `ArrayList` of `String`s.\n\nCheck out the keypad mapping below for reference.\n\n**Note:**\n* You can assume that the input String contains only numbers between 2 and 9\n* The `combinations` should be return in alphabetical order\n\nMapping:\n* 2 -> \"abc\"\n* 3 -> \"def\"\n* 4 -> \"ghi\"\n* 5 -> \"jkl\"\n* 6 -> \"mno\"\n* 7 -> \"pqrs\"\n* 8 -> \"tuv\"\n* 9 -> \"wxyz\"\n\n### Examples\n\n* `34` -> `[dg, dh, di, eg, eh, ei, fg, fh, fi]`","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"getStringsFromNums","returnStatement":{"type":"java.util.ArrayList","comment":"Combinations","generic":"String"},"parameters":[{"name":"digits","type":"java.lang.String","comment":"digits pressed on a classic cell phone keypad"}]},"testCases":[{"input":["34"],"output":["dg","dh","di","eg","eh","ei","fg","fh","fi"]},{"input":["23"],"output":["ad","ae","af","bd","be","bf","cd","ce","cf"]},{"input":["232"],"output":["ada","adb","adc","aea","aeb","aec","afa","afb","afc","bda","bdb","bdc","bea","beb","bec","bfa","bfb","bfc","cda","cdb","cdc","cea","ceb","cec","cfa","cfb","cfc"]},{"input":["6"],"output":["m","n","o"]},{"input":["8"],"output":["t","u","v"]}]},
73-
{"id":"max-cont-sequence","title":"Maximum Contiguous Subsequence","description":"Given an array of integers consisting of both positive and negative numbers, write a method `maxContSequence` to find the contiguous subsequence that has the **maximum sum** among all `subsequences` in the array.\n\nYour method should return `res` array containing 3 integers in the following format:\n```\nres[0] = max sum\nres[1] = starting index of the subsequence\nres[2] = ending index of the subsequence\n```\n\n**Note**\n* In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence `<A,B,D>` is a subsequence of `<A,B,C,D,E,F>`. They should not be confused with substring which is a refinement of subsequence.\n* you can check wikipedia for more details\n* for empty input, return `[0,0,-1]`\n\n### Examples\n\n* `[-1,-2,3,4,5]` -> `[12,2,4]`\n* `[1,2,3,-2,5]` -> `[9,0,4]`","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"maxContSequence","returnStatement":{"type":"[I","comment":"Result containing 3 integers, max sum, starting and ending index of the subsequence"},"parameters":[{"name":"arr","type":"[I","comment":"array of integers"}]},"testCases":[{"input":[[-1,-2,3,4,5]],"output":[12,2,4]},{"input":[[1,2,3,-2,5]],"output":[9,0,4]},{"input":[[]],"output":[0,0,-1]},{"input":[[-1,30,-4,20,20,-11]],"output":[66,1,4]},{"input":[[1,2,3,4,5,6]],"output":[21,0,5]},{"input":[[-1,-2,-3,-4,-5,-6]],"output":[-1,0,0]}]}]
73+
{"id":"max-cont-sequence","title":"Maximum Contiguous Subsequence","description":"Given an array of integers consisting of both positive and negative numbers, write a method `maxContSequence` to find the contiguous subsequence that has the **maximum sum** among all `subsequences` in the array.\n\nYour method should return `res` array containing 3 integers in the following format:\n```\nres[0] = max sum\nres[1] = starting index of the subsequence\nres[2] = ending index of the subsequence\n```\n\n**Note**\n* In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence `<A,B,D>` is a subsequence of `<A,B,C,D,E,F>`. They should not be confused with substring which is a refinement of subsequence.\n* you can check wikipedia for more details\n* for empty input, return `[0,0,-1]`\n\n### Examples\n\n* `[-1,-2,3,4,5]` -> `[12,2,4]`\n* `[1,2,3,-2,5]` -> `[9,0,4]`","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"maxContSequence","returnStatement":{"type":"[I","comment":"Result containing 3 integers, max sum, starting and ending index of the subsequence"},"parameters":[{"name":"arr","type":"[I","comment":"array of integers"}]},"testCases":[{"input":[[-1,-2,3,4,5]],"output":[12,2,4]},{"input":[[1,2,3,-2,5]],"output":[9,0,4]},{"input":[[]],"output":[0,0,-1]},{"input":[[-1,30,-4,20,20,-11]],"output":[66,1,4]},{"input":[[1,2,3,4,5,6]],"output":[21,0,5]},{"input":[[-1,-2,-3,-4,-5,-6]],"output":[-1,0,0]}]},
74+
{"id":"factorial","title":"Factorial","description":"Write the `factorial` method to return unity digit of the factorial of n (`n!`).\n\n### Notes\n* for `n <= 1` we have `n! = 1`\n\n### Examples\n\n* `4` -> `4`","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"factorial","returnStatement":{"type":"java.lang.Integer","comment":"Unity digit of the factorial"},"parameters":[{"name":"n","type":"java.lang.Integer","comment":"Input number for factorial"}]},"testCases":[{"input":[4],"output":4},{"input":[0],"output":1},{"input":[1],"output":1},{"input":[3],"output":6},{"input":[4],"output":4},{"input":[5],"output":0},{"input":[6],"output":0},{"input":[7],"output":0},{"input":[21351],"output":0},{"input":[29999],"output":0}]},
75+
{"id":"country-postman","title":"Country postman","description":"Country postman has to delivery the mail all the inhabitants of the area, who live in the villages and next to the roads linking villages.\n\nYou need to help pave the postman route - find a path that will allow him to ride along every road and visit every village in the area at least once. That's fortunate that in the considered examples of such a route is always there. However, the marked routes may differ quality, ie. the postman can receive different payment for his work depending on the chosen route (as we will see, it does not gain the postman is the most important, but the profit of his company, the post office).\n\nThe inhabitants of each village would like to postman reached them as soon as possible. Each village has concluded with the post office the following agreement: if `i'th` village is visited by the postman as `k'th` in order (means the postman visited already `k - 1` other villages before he reached `i'th` village) and `k <= w(i)`, then village pays the post office `w(i) - k`CHF. Although, if `k > w(i)`, then the post office pays village `k - w(i)`CHF. \n\nMoreover, the post office pays to country postman one CHF for each passage between two successive villages along his route.\n\n### Notes\n* We mark villages with `id` - which is number between `1..n`, `n` is number of villages.\n* The post office is located in the village identified by a number `1` and thus the postman route must begin in this village.\n* In each village coincides 2, 4 or 8 roads.\n* Between the two villages there may be several different ways; the road may also return to the same village, from which it emerged.\n\nWrite method `findPath` to find the route that runs through every village and along every road, and which achieves the post maximum profit (or suffer minimal loss).\n\nIf there is more than one solution, your program should calculate one of them.\n\n### Input\n* `villages` - id of village is `i = index + 1`, the values in array represents `w(i)`, where `1<=w(i) <= 1000`, that is the initial amount paid by the village to the post office number `i` (this amount is obviously modified as described at the beginning of the task the way).\n* `roads` - array of paths, every path contains two village ids which it connects\n\n### Examples\n\n* `[1,7,4,10,20,5], [[2,4],[1,5],[2,1],[4,5],[3,6],[1,6],[1,3]]` -> `[1,5,4,2,1,6,3,1]`\n","timeLimit":1,"memoryLimit":32,"level":3,"func":{"name":"findPath","returnStatement":{"type":"[I","comment":"Array of village ids as the most optimal path for country postman"},"parameters":[{"name":"villages","type":"[I","comment":"array of village ids"},{"name":"roads","type":"[[I","comment":"paths joining different villages"}]},"testCases":[{"input":[[1,7,4,10,20,5],[[2,4],[1,5],[2,1],[4,5],[3,6],[1,6],[1,3]]],"output":[1,5,4,2,1,6,3,1]},{"input":[[1,2,5,1,12,2,3],[[1,2],[7,7],[2,5],[3,7],[4,3],[1,4],[5,2],[2,3],[3,6],[6,6],[6,7]]],"output":[1,2,5,2,3,7,7,6,6,3,4,1]},{"input":[[1,1,1,1,1,1,1,1,1,1],[[7,7],[4,10],[2,7],[1,3],[5,4],[10,4],[3,1],[3,8],[8,7],[4,5],[7,8],[4,3],[5,1],[5,2],[6,7],[7,4],[9,9],[8,9],[8,8],[4,4],[8,3],[7,6],[6,1],[2,2],[3,2],[5,2],[9,6],[1,1],[2,5],[3,10],[10,8],[1,5],[1,5],[2,3]]],"output":[1,3,1,5,4,10,4,5,2,2,7,7,8,3,4,4,7,6,7,8,8,3,2,5,2,3,10,8,9,9,6,1,1,5,1]},{"input":[[32,32,25,15,64,49,87,28,72,85,75,79,56,85,97,37,86,31,81,80],[[5,7],[9,10],[15,17],[1,10],[10,9],[20,19],[6,5],[14,16],[19,20],[2,1],[13,15],[6,8],[11,13],[16,15],[12,11],[13,14],[4,3],[20,10],[10,12],[7,8],[15,16],[18,20],[2,4],[16,18],[1,2],[4,6],[8,7],[9,11],[7,9],[17,18],[11,12],[18,17],[2,1],[5,6],[1,1],[14,13],[3,5],[8,10],[3,4],[1,20],[20,19],[20,20],[17,19],[1,3],[10,10],[12,14]]],"output":[1,2,1,1,10,9,10,12,11,13,15,16,14,13,14,12,11,9,7,5,6,8,7,8,10,10,20,19,20,18,16,15,17,18,17,19,20,20,1,2,4,3,5,6,4,3,1]},{"input":[[35,95,25,8,10,98,52,45,25,6,55,46,46,52,61,7,9,43,92,79,84,28,52,75,12,100,58,56,83,64,22,47,94,78,40,22,10,63,34,46],[[2,19],[20,20],[8,9],[8,3],[39,40],[35,13],[25,26],[9,13],[37,21],[2,21],[34,2],[22,38],[36,12],[27,28],[40,1],[32,40],[9,3],[6,6],[10,19],[30,28],[20,39],[12,13],[25,3],[29,9],[11,3],[18,6],[22,15],[17,18],[23,24],[4,5],[10,10],[29,30],[31,13],[18,19],[15,15],[35,40],[16,17],[9,20],[3,4],[8,4],[13,14],[21,25],[28,11],[8,8],[33,24],[31,19],[21,16],[31,34],[4,27],[36,35],[30,31],[9,10],[5,38],[17,16],[18,18],[21,22],[37,38],[36,37],[9,9],[21,19],[3,14],[10,11],[2,3],[27,26],[32,33],[11,25],[32,2],[38,38],[34,35],[4,4],[31,32],[25,18],[13,29],[36,18],[31,40],[22,24],[33,34],[4,36],[20,34],[35,14],[32,35],[17,11],[15,13],[11,23],[16,13],[26,27],[36,36],[1,2],[6,7],[28,29],[11,2],[30,1],[12,25],[32,10],[14,15],[28,26],[8,6],[19,37],[38,30],[23,23],[30,19],[35,28],[20,21],[7,8],[8,30],[15,16],[10,40],[22,23],[23,22],[14,14],[24,25],[34,32],[15,16],[22,28],[15,10],[16,16],[35,36],[11,12],[33,4],[40,38],[23,32],[1,5],[14,22],[30,31],[28,39],[25,18],[38,39],[3,6],[5,6],[19,20],[23,2],[20,21],[34,34],[14,6],[40,31]]],"output":[1,40,39,20,20,9,8,8,3,9,29,30,28,11,3,25,21,2,19,10,10,9,9,13,35,36,12,13,31,34,35,40,32,33,34,2,32,31,19,18,18,17,16,17,11,25,18,6,6,8,4,3,14,13,29,28,27,4,4,5,38,22,15,15,13,16,21,37,36,36,4,33,24,23,23,11,10,32,35,14,14,15,16,16,15,10,40,31,30,1,2,11,12,25,26,27,26,28,35,36,18,25,24,22,23,22,21,19,37,38,38,30,19,20,21,20,34,34,32,23,2,3,6,7,8,30,31,40,38,39,28,22,14,6,5,1]},{"input":[[12,266,129,692,640,907,337,828,382,413,559,495,342,717,291,798,855,855,41,651,813,570,673,892,385,815,813,94,775,896,851,555,364,519,488,189,517,652,663,654,721,586,238,392,505,663,288,82,901,8,169,179,251,109,993,110,668,638,876,244,868,553,203,267,404,981,779,451,777,111,201,960,212,935,175,749,385,580,100,74,372,963,293,241,932,884,682,201,308,270,984,986,65,106,970,83,775,615,232,109],[[19,12],[88,15],[63,38],[50,2],[1,50],[30,3],[37,100],[21,21],[70,72],[22,95],[23,79],[28,58],[33,98],[14,42],[28,19],[2,71],[36,83],[32,42],[24,69],[72,8],[84,97],[44,83],[75,49],[79,63],[35,11],[16,69],[74,50],[23,31],[92,1],[99,32],[83,66],[78,43],[88,88],[36,83],[47,6],[12,4],[70,92],[64,11],[70,39],[77,42],[68,58],[3,50],[59,59],[76,47],[6,47],[85,27],[84,84],[60,66],[29,13],[17,26],[72,76],[16,39],[76,18],[34,89],[74,81],[100,47],[31,23],[86,36],[48,19],[79,85],[41,41],[93,40],[96,31],[59,41],[46,60],[58,68],[15,65],[91,34],[84,42],[90,72],[77,52],[19,95],[82,21],[96,80],[51,28],[8,72],[86,66],[87,25],[73,73],[63,34],[9,21],[74,8],[58,81],[55,14],[14,55],[8,74],[6,53],[55,44],[61,56],[52,77],[22,10],[4,54],[89,77],[47,76],[12,44],[22,86],[86,22],[55,99],[61,15],[40,73],[94,54],[85,79],[95,57],[27,24],[65,8],[67,44],[71,35],[50,2],[95,19],[97,98],[17,78],[12,24],[33,38],[73,27],[65,61],[66,60],[82,78],[19,19],[38,33],[83,36],[31,29],[21,5],[28,14],[21,82],[42,75],[99,55],[20,61],[17,48],[10,87],[48,11],[36,36],[64,87],[45,79],[5,17],[50,74],[23,12],[90,10],[87,55],[16,31],[7,94],[75,6],[94,89],[92,66],[49,79],[81,63],[8,65],[31,16],[24,2],[71,88],[42,14],[61,64],[4,73],[41,6],[44,12],[29,35],[19,28],[75,53],[10,22],[15,41],[72,70],[39,67],[23,71],[82,30],[25,65],[10,5],[28,51],[70,99],[62,69],[89,94],[76,100],[44,84],[3,28],[52,85],[95,96],[26,62],[81,45],[44,67],[92,84],[68,8],[43,9],[1,24],[16,16],[4,39],[2,24],[48,48],[41,15],[80,96],[27,73],[61,65],[9,9],[100,37],[76,32],[48,17],[66,92],[54,99],[94,81],[100,76],[10,100],[58,54],[90,90],[51,94],[5,86],[46,78],[3,3],[49,55],[42,77],[39,27],[14,28],[18,56],[57,82],[52,34],[11,48],[69,32],[33,33],[65,90],[6,75],[69,62],[12,23],[9,67],[89,89],[68,59],[47,67],[15,7],[57,95],[50,3],[24,12],[63,81],[57,31],[38,35],[72,90],[99,99],[5,21],[59,68],[78,46],[46,88],[39,4],[29,100],[52,89],[65,15],[34,63],[77,77],[64,4],[85,52],[66,6],[32,69],[54,58],[34,48],[90,54],[27,29],[13,68],[35,71],[96,59],[88,46],[3,62],[62,14],[25,87],[24,1],[67,47],[45,85],[64,61],[85,58],[25,26],[78,17],[37,22],[87,87],[11,11],[8,74],[71,93],[80,80],[94,7],[58,85],[80,16],[27,39],[75,97],[55,49],[15,88],[33,35],[40,82],[26,25],[69,51],[17,36],[63,63],[36,17],[79,49],[60,70],[32,32],[59,96],[83,44],[2,80],[49,49],[87,10],[100,29],[95,97],[13,23],[71,23],[32,76],[62,9],[46,46],[67,9],[83,83],[14,52],[96,96],[53,59],[78,82],[54,4],[35,33],[91,92],[68,13],[67,64],[11,33],[54,90],[98,97],[97,95],[92,91],[79,45],[57,37],[62,3],[99,70],[42,84],[47,80],[77,20],[84,92],[66,86],[86,5],[7,86],[69,16],[11,64],[25,22],[73,40],[31,57],[4,64],[53,75],[81,94],[34,52],[2,50],[21,46],[97,75],[49,57],[41,78],[93,71],[56,61],[89,34],[98,25],[73,93],[97,72],[56,5],[22,25],[39,70],[5,10],[81,74],[6,41],[29,27],[82,57],[35,29],[80,2],[9,62],[74,91],[88,68]]],"output":[1,50,74,81,58,68,58,28,19,48,48,17,78,43,9,9,21,21,82,30,3,50,2,71,35,11,64,87,10,22,95,19,19,95,57,82,78,46,60,66,86,22,10,90,90,72,8,74,8,72,70,92,66,83,36,83,44,55,14,42,77,52,77,77,89,34,63,38,33,98,97,84,84,42,32,99,55,14,28,51,28,19,12,4,54,94,89,89,94,81,63,79,23,31,23,12,44,67,39,16,69,24,27,73,73,4,39,70,72,76,47,6,47,100,37,100,76,18,56,61,15,65,8,68,59,59,41,41,15,88,88,46,46,78,82,21,5,17,26,62,69,32,76,47,67,44,12,24,2,50,74,8,65,61,64,4,39,27,85,79,85,52,34,63,63,81,45,79,49,75,6,53,75,42,14,28,3,3,62,69,51,94,7,15,41,6,75,97,95,96,80,80,96,31,16,16,31,29,13,68,59,96,96,59,53,75,97,95,57,31,57,37,22,86,36,36,83,83,44,84,92,66,6,41,78,17,36,17,48,11,11,48,34,91,92,1,24,2,80,47,67,9,62,3,50,2,80,16,69,32,32,76,100,10,5,86,66,60,70,99,99,55,49,55,87,25,26,25,65,61,20,77,42,84,92,91,74,81,94,7,86,5,21,46,88,71,35,38,33,33,35,29,100,29,27,73,40,93,71,23,13,68,88,15,65,90,72,97,98,25,22,25,87,87,10,5,56,61,64,11,33,35,29,27,39,70,99,54,58,54,90,54,4,64,67,9,62,14,52,89,34,52,85,58,85,45,79,49,49,57,82,40,73,93,71,23,12,24,1]}]}]

0 commit comments

Comments
 (0)