Skip to content

Commit 1d7e614

Browse files
committed
- problem fixes
- add clarifying example for find middle node - update Reverse Level Order Traversal description
1 parent e34d52f commit 1d7e614

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

ProblemsStore/00000000000.xd

102 Bytes
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', '18', System.env.TRAVIS_BUILD_NUMBER
3+
'1', '0', '19', System.env.TRAVIS_BUILD_NUMBER
44
)
55

66
println "Version number: " + version

problems.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
{"id":"sort-array","title":"Sort Array","description":"Write method `sort` to sort given array.\r\n\r\n**Note**: You cannot use `Arrays.sort` or any other framework method to do that - you have to implement it.\r\n\r\n### Example\r\n\r\n* `[44,2,22,7,11,15]` -> `[2,7,11,15,22,44]`","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"sort","returnStatement":{"type":"[I","comment":" Sorted array"},"parameters":[{"name":"arr","type":"[I","comment":"An array to sort"}]},"testCases":[{"input":[[44,2,22,7,11,15]],"output":[2,7,11,15,22,44]},{"input":[[1]],"output":[1]},{"input":[[]],"output":[]},{"input":[null],"output":null},{"input":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,9,9,9,10,11,1001,2001,198,201,203,201,999,345,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,1,2,2,2,2,2,2,2,2,2,4,5,6,1,1,1,1,1,1,1,1,1,1,1,101,1,1,1,1,1,1,1,1]],"output":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,4,5,6,9,9,9,10,11,101,198,201,201,203,345,999,1001,2001]}]},
4141
{"id":"string-compress","title":"String Compression","description":"Implement a method `compress` to perform basic string compression using the counts of repeated characters. \r\n\r\nIf the **compressed** string would not become smaller than original string, your method should return original string. \r\n\r\n**Note**: You can assume the string has only uppercase and lowercase letters (a-z).\r\n\r\n### Examples\r\n\r\n* `\"aabcccccaaa\"` -> `\"a2b1c5a3\"`","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"compress","returnStatement":{"type":"java.lang.String","comment":" Compressed string."},"parameters":[{"name":"str","type":"java.lang.String","comment":"String to compress"}]},"testCases":[{"input":["aabcccccaaa"],"output":"a2b1c5a3"},{"input":["Julia"],"output":"Julia"},{"input":[""],"output":""},{"input":[null],"output":null},{"input":["JjuuLLiiiiAaaaaAAaaaaa"],"output":"J1j1u2L2i4A1a4A2a5"},{"input":["JjuuLLiiiiAaaaaAAaBCDEFG"],"output":"JjuuLLiiiiAaaaaAAaBCDEFG"},{"input":["JJJJJJJJJJJ"],"output":"J11"}]},
4242
{"id":"sum-lists","title":"Sum Lists","description":"You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write method `addLists` that adds the two numbers and returns the sum as a linked list.\r\n\r\n### Examples\r\n\r\n* `7->1->6, 5->9->2` -> `2->1->9` (617 + 295 = 912)","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"addLists","returnStatement":{"type":"com.jalgoarena.type.ListNode","comment":" linked list node containing result of sum"},"parameters":[{"name":"l1","type":"com.jalgoarena.type.ListNode","comment":"First Linked List to add"},{"name":"l2","type":"com.jalgoarena.type.ListNode","comment":"Second Linked List to add"}]},"testCases":[{"input":[[7,1,6],[5,9,2]],"output":[2,1,9]},{"input":[[7,6,5,4,1],[9,3,1]],"output":[6,0,7,4,1]},{"input":[[7,6,5,4,1],[]],"output":[7,6,5,4,1]},{"input":[[1],[9,3,1]],"output":[0,4,1]},{"input":[[9],[1]],"output":[0,1]},{"input":[[],[]],"output":[]}]},
43-
{"id":"find-middle-node","title":"Find Middle Node","description":"Given a singly linked list, write a method `findMiddleNode` to find and return the middle node of the list.\r\n\r\n### Examples\r\n\r\n* `1->2->3->4->5` -> `3->4->5`","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"findMiddleNode","returnStatement":{"type":"com.jalgoarena.type.ListNode","comment":" Middle node"},"parameters":[{"name":"head","type":"com.jalgoarena.type.ListNode","comment":"Linked List head"}]},"testCases":[{"input":[[1,2,3,4,5]],"output":[3,4,5]},{"input":[[1]],"output":[1]},{"input":[[1,2]],"output":[1,2]},{"input":[[]],"output":null},{"input":[null],"output":null},{"input":[[5,3,2,1]],"output":[3,2,1]}]},
43+
{"id":"find-middle-node","title":"Find Middle Node","description":"Given a singly linked list, write a method `findMiddleNode` to find and return the middle node of the list.\n\n### Examples\n\n* `1->2->3->4->5` => `3->4->5`\n* `1->2->3->4->5->6` => `3->4->5->6`","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"findMiddleNode","returnStatement":{"type":"com.jalgoarena.type.ListNode","comment":" Middle node"},"parameters":[{"name":"head","type":"com.jalgoarena.type.ListNode","comment":"Linked List head"}]},"testCases":[{"input":[[1,2,3,4,5]],"output":[3,4,5]},{"input":[[1]],"output":[1]},{"input":[[1,2]],"output":[1,2]},{"input":[[]],"output":null},{"input":[null],"output":null},{"input":[[5,3,2,1]],"output":[3,2,1]}]},
4444
{"id":"height-binary-tree","title":"Height of a Binary Tree","description":"Given a binary tree, write a method `findHeight` to find its height. An empty tree has a height of 0.\r\n\r\n### Example\r\n\r\n ```\r\n 1\r\n / \\\r\n 2 3 ==> height = 3\r\n / \\ / \\\r\n 4 5 6 7 \r\n```","timeLimit":1,"memoryLimit":32,"level":1,"func":{"name":"findHeight","returnStatement":{"type":"java.lang.Integer","comment":" Height of binary tree"},"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":3},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}}],"output":4},{"input":[{"data":1}],"output":1},{"input":[null],"output":0}]},
4545
{"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}]},
4646
{"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}]},
@@ -56,7 +56,7 @@
5656
{"id":"matrix-max-sum-path","title":"Matrix Max Sum Path","description":"You are given an `m x n` matrix filed with non-negative integers. Write method `matrixMaxSum` to find the maximum sum along a path from the top-left of the grid to the bottom-right. Return this maximum sum.\n\nThe direction of movement is limited to right and down.\n\n### Examples\n\n```\n 1 2 3\n 4 5 6\n 7 8 9\n\n=> 1 + 4 + 7 + 8 + 9 = 29\n```","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"matrixMaxSum","returnStatement":{"type":"java.lang.Integer","comment":"Max sum"},"parameters":[{"name":"matrix","type":"[[I","comment":"Matrix to check"}]},"testCases":[{"input":[[[1,2,3,4],[5,6,7,8],[9,0,1,2],[3,4,5,0]]],"output":29},{"input":[[[1,2,3],[4,5,6],[7,8,9]]],"output":29},{"input":[[[1,1,1],[1,1,1],[1,1,1]]],"output":5},{"input":[[[1]]],"output":1},{"input":[[[1,2],[3,4]]],"output":8},{"input":[[[1,2,3],[4,5,6]]],"output":16}]},
5757
{"id":"merge-k-sorted-linked-lists","title":"Merge k Sorted Linked Lists","description":"Write a method `mergeKLists` to merge k **Sorted** `LinkedList`. \n\nWhy would you ever want to do that? Well, if you're dealing with a list of over 200 Million `Integers` that needs to be sorted, an efficient approach might involve splitting up the massive list into `k` smaller lists, sorting each list in memory and then combining the sorted lists to re-create the original list, albeit sorted.\n\n### Example\n```\n* 1->2->13->20\n* 1->20->35->40\n* 5->6->12->18\n\n=> 1->1->2->5->6->12->13->18->20->20->35->40\n```","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"mergeKLists","returnStatement":{"type":"com.jalgoarena.type.ListNode","comment":"Merged Linked List"},"parameters":[{"name":"lists","type":"java.util.ArrayList","comment":"List of Sorted Linked Lists","generic":"ListNode"}]},"testCases":[{"input":[[[1,2,13,20],[1,20,35,40],[5,6,12,18]]],"output":[1,1,2,5,6,12,13,18,20,20,35,40]},{"input":[[[1,2,3,4,5],[1,2,3,4],[8]]],"output":[1,1,2,2,3,3,4,4,5,8]},{"input":[[[2,4,13,40],[1,5,12,14],[8],[6,7,9]]],"output":[1,2,4,5,6,7,8,9,12,13,14,40]},{"input":[[[2,4,13,45],[1,5,12,14],[8],[60,70,82,89,90],[46,65]]],"output":[1,2,4,5,8,12,13,14,45,46,60,65,70,82,89,90]},{"input":[[[1],[1],[1],[1],[1]]],"output":[1,1,1,1,1]},{"input":[[[1,2]]],"output":[1,2]}]},
5858
{"id":"find-max-sum-level","title":"Find Max Sum Level","description":"Given a binary tree, Write a method `findMaxSumLevel` to return the level that has the maximum sum. In case the tree is empty return -1.\n\n### Example\n\n ```\n0 1\n / \\\n1 2 3 ==> 2\n / \\ / \\\n2 4 5 6 7 \n```","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"findMaxSumLevel","returnStatement":{"type":"java.lang.Integer","comment":"Level that has the Maximum Sum"},"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":2},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}}],"output":2},{"input":[{"data":21,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}}],"output":0},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6,"left":{"data":7},"right":{"data":8}}}}}],"output":4},{"input":[{"data":1}],"output":0},{"input":[null],"output":-1}]},
59-
{"id":"rev-level-order-traversal","title":"Reverse Level Order Traversal","description":"Given a binary tree, Write a method `postorderTraversal` to traverse the tree in the postorder manner. Return array of elements visited in postorder format.\n\n### Example\n\n ```\n 1\n / \\\n 2 3 ==> 4567231\n / \\ / \\\n 4 5 6 7 \n```","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"levelorderRev","returnStatement":{"type":"[I","comment":"Reverse level ordered array of binary tree elements"},"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":[4,5,6,7,2,3,1]},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}}],"output":[6,4,7,2,3,1]},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6,"left":{"data":7},"right":{"data":8}}}}}],"output":[7,8,6,4,7,2,3,1]},{"input":[{"data":1}],"output":[1]},{"input":[null],"output":[]}]},
59+
{"id":"rev-level-order-traversal","title":"Reverse Level Order Traversal","description":"Given a binary tree, Write a method `levelorderRev ` to traverse the tree in the reversed level order manner. Return array of elements visited in reversed level order format.\n\n### Example\n\n ```\n 1\n / \\\n 2 3 ==> 4567231\n / \\ / \\\n 4 5 6 7 \n```","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"levelorderRev","returnStatement":{"type":"[I","comment":"Reverse level ordered array of binary tree elements"},"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":[4,5,6,7,2,3,1]},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}}],"output":[6,4,7,2,3,1]},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6,"left":{"data":7},"right":{"data":8}}}}}],"output":[7,8,6,4,7,2,3,1]},{"input":[{"data":1}],"output":[1]},{"input":[null],"output":[]}]},
6060
{"id":"word-similarity","title":"Word Similarity - Edit Distance","description":"Edit distance is a classic algorithm that is used in many applications, including Spell Correction, DNA Sequencing and Natural Language Processing. Given two strings `a` and `b`, write a method - `editDistance` that returns the **minimum number of operations** needed to transform `a` into `b`. The following character operations are allowed:\n* Replace character\n* Insert character\n* Delete character\n\n### Examples\n\n```\n\"sale\", \"sales\" => 1\n\n1) Insert \"s\"\n```\n\n```\n\"sale\", \"sold\" => 2\n\n1) Replace \"a\" with \"o\"\n2) Replace \"e\" with \"d\"\n```\n\n```\n\"sa\", \"s\" => 1\n\n1) Delete \"a\"\n```","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"editDistance","returnStatement":{"type":"java.lang.Integer","comment":"Minimum number of operations"},"parameters":[{"name":"a","type":"java.lang.String","comment":"input string to be transformed"},{"name":"b","type":"java.lang.String","comment":"destination string"}]},"testCases":[{"input":["","a"],"output":1},{"input":[null,""],"output":0},{"input":["",null],"output":0},{"input":["",""],"output":0},{"input":[null,null],"output":0},{"input":["css","dll"],"output":3},{"input":["sale","sales"],"output":1},{"input":["sale","sold"],"output":2},{"input":["sa","s"],"output":1},{"input":["confusion","confusing"],"output":2},{"input":["abc","adef"],"output":3},{"input":["coding","code"],"output":3},{"input":["ATGCATGGCCAATTGCCAAT","ATCGATCGATCG"],"output":12},{"input":["ATGCATGGCCAAAATTTTAAAAATAGAGAGATTTCCCAATTGCCAAT","ATCGATCGATCGAATTA"],"output":32},{"input":["interview","intuition"],"output":5},{"input":["saturday","sunday"],"output":3}]},
6161
{"id":"subset-summation","title":"Subset Summation","description":"Given an array of integers and a target number, determine if it is possible to choose a group of integers from the array, such that the numbers in the group sum to the given target.\n\n### Example\n\n* `[1,2,3,6,5], 10` -> `true`\n* `[1,2,3,6,5], 18` -> `false`","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"groupSum","returnStatement":{"type":"java.lang.Boolean","comment":"Is possible to find sum"},"parameters":[{"name":"numbers","type":"[I","comment":"An array of numbers","generic":null},{"name":"target","type":"java.lang.Integer","comment":"Target sum number","generic":null}]},"testCases":[{"input":[[2,7,11,15],9],"output":true},{"input":[[1,2,3,6,5],10],"output":true},{"input":[[1,2,3,6,5],18],"output":false},{"input":[[1,0,-1],2],"output":false},{"input":[[1,-3,-4],-2],"output":true},{"input":[[],1],"output":false},{"input":[[1,2,5,6,7,3,5,8,-33,-5,-72,12,-34,100,99],-64],"output":true},{"input":[[1,2,33,23,2423,33,23,1,7,6,8787,5,33,2,3,-23,-54,-67,100,400],390],"output":true},{"input":[[-1,-2,-3,-4,-5,-6,-100,-98,-111,-11],-70],"output":false}]},
6262
{"id":"longest-nr-substring-len","title":"Longest Non-Repeating Substring","description":"Given a `String` input, write a method `longestNRSubstringLen` to find the length of the longest `substring` that is made up of non-repeating characters.\n\n### Examples\n\n* `\"BCEFGHBCFG\"` -> `6` (\"CEFGHB\" or \"EFGHBC\")\n* `\"FFFFF\"` -> `1` (\"F\")\n* `\"aaabbbabcde\"` -> `5`","timeLimit":1,"memoryLimit":32,"level":2,"func":{"name":"longestNRSubstringLen","returnStatement":{"type":"java.lang.Integer","comment":"Length of longest non-repeating substring"},"parameters":[{"name":"input","type":"java.lang.String","comment":"input string","generic":null}]},"testCases":[{"input":[""],"output":0},{"input":[null],"output":0},{"input":["abc"],"output":3},{"input":["AdSda"],"output":5},{"input":["BCEFGHBCFG"],"output":6},{"input":["FFFFF"],"output":1},{"input":["aaaabcdnha"],"output":6},{"input":["ABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-.ABCDEFGHIJKLMNOPQRSTUVWXYZ/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz{|}~"],"output":148}]},

0 commit comments

Comments
 (0)