Skip to content

Commit

Permalink
fix one of test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
spolnik committed Sep 18, 2018
1 parent 7790121 commit f816bd9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/resources/problems.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{"id":"binary-distributions","title":"Binary Distributions","description":"Binary distribution of number `n` is a sequence of \"digits\" a~k~a~k-1~...a~1~a~0~ such that:\n* every digit a~0~, a~1~,...,a~k~ is equal 1, 0 or -1\n* the most significant digit in the distribution is always different from zero\n* n = a~k~ * 2^k^ + a~k-1~ * 2^k-1^ + ... + a~1~ * 2 + a~0~\n\nYou can easily notice that the number can have many different binary distributions. Of these distributions, the **optimal** we call those that have the fewest number of non-zero digits. For example, binary distributions of `15` are: 1000++1++, 1111 and 100++1++1 (for your convenience -1 is marked in here as ++1++). The first of these distributions is an optimal one for number `15`.\n\nWrite a method `findOptimal` that will calculate what is the number of nonzero digits in the optimal distributions of binary number.\n\n### Notes\n* the input can have from 1 to 500 digits \n* the inputs most significant digit is always different than 0\n\n### Examples\n\n* `15` -> `2`","timeLimit":1,"level":3,"func":{"name":"findOptimal","returnStatement":{"type":"java.lang.Integer","comment":"The number of nonzero digits in the optimal distributions of binary number."},"parameters":[{"name":"input","type":"java.lang.String","comment":"Input number"}]},"testCases":[{"input":["15"],"output":2},{"input":["127"],"output":2},{"input":["955"],"output":4},{"input":["1"],"output":1},{"input":["74780630500293123829"],"output":24},{"input":["4745064555945020949896559907430798058510509104382522902803157451795069209839906341407506695386136568"],"output":107},{"input":["62296902881696353197411596458457581217963255881729338045251466307454125965893098317613589823307940160334223730860302496813509682752731768971454542860916853681223913543053145181406290243303152877188301419202895669316734469353910460359686818802051775327331559870162757972179837755243635533824736162185903035357268563062231176722567240378359072731440161684746009647798379986447582869419795581707676979035166684781827164946262050485604767155913255301585863363734544444490570506739370351934530618885949914"],"output":552},{"input":["1564382205298691725388488404021328945615347938733150494072866127332180055361186980954806824192719482508135144756648769178060298710993062932943782573488871914849723619228813520224045285158035375349209481122585545095278019766487919267039896299945221811979208004676181085468800224264731768686073817009669805304867006735108371838421658519440139943832700568269689268958602757101473448647902292343771927145477772119505696966417376506294563732581059870693961171029232821035670097728299231318488050040832"],"output":1},{"input":["100120461139116270424863257857365052519382268078921631620663432149259523543115966781107636748334046880520649264425521227395859117503556027708402084703287802550382311630644065294338898250114264022349406791845474886097793265055226833090553363196494195966669312299275589470003214352942833195908724288618867539511488431046935797658986145244168956405292836369260113213350576454494300713465746710001403337310577415648364605850712096402852078885187831724413514945870900546282886254611150804383235202613247"],"output":2},{"input":["151765048241814338969657392010299270197996320468097158210280868160012571544812039642401391193340482278352054685494781896516632086034035982733260857008171725208106957068357686533907475450351230426575976998485619463732584434569960699401164922159438895758086971150495915738555314045004757032542820962618357861343442029233204262798890560655868218729806110133813662004211098450611796448152967529194034397900664491996644158538874908728230485826600718495703881589893020867570894937991322883414"],"output":806},{"input":["174020204733138657868739588587219257440344336295600461055802267977458203173219967032916812902936991584443880587697628495069454828428264659900638003630169039606672160349630972591853790976373492336470658886545392875768184249844452989105592727725603517794973218262715378325109313433636793338408840043910760859344908511303227990753688093001474513321493241965049145446395648612542480787606325087178605235004684559832935110867485825623927465980997527959037840002463884043990689646632968"],"output":160}]},
{"id":"dichroic-towers-hanoi","title":"Dichroic Towers of Hanoi","description":"Towers of Hanoi is a traditional fun-puzzle involving the imposition of discs in the rods. Having `n` discs with diameters `1, 2, ..., n` and three rods, which we call `A`, `B` and `C`. Each disc has a hole in the middle that allows you put the disk on the rod.\n\nInitially all disks are located on the `A` rod and they are arranged starting from largest (at the bottom) to the smallest (top). The game is to move all the disks on one of the empty rods (let's say `B`) according to the following rules:\n\n* in one move, we must take a disk laying on top of one of the rods and put it on top of another one;\n* for each rod you have to preserve order, i.e. discs must be in order from largest (at the bottom of the rod) to the smallest (top).\n\nBy tower we call all the disks laying on one rod. To summarise the above rules, we can conclude that:\n\n* you cannot take the disc from the center of the tower and insert the disc into the middle of tower;\n* you cannot take more than one disc at a time;\n* you cannot put a larger disc on a smaller one.\n\nThe objective in this game is to move the tower from one post to another in the smallest possible number of moves.\n\nDichroic Towers of Hanoi is a slightly modified version of the above puzzle. As before, there are three rods and `n` disks with diameters `1, 2, ..., n`. This time, however discs with odd diameter (`1, 3, 5, ...`) are white and discs with even diameter (`2, 4, 6, ...`) are black. The aim of the play is to move (as with the above principles) all the white disks on the `B` rod and all the black discs on the `C` rod.\n\nWrite a method `countMoves` that calculates the minimum number of moves needed to move all white discs on a `B` rod, and a black discs on a `C` rod.\n\n### Notes\n* `0 <= n <= 1000`\n\n### Examples\n\n* `6` -> `45`","timeLimit":1,"level":3,"func":{"name":"countMoves","returnStatement":{"type":"java.lang.String","comment":"Minimal number of moves needed to finish a game."},"parameters":[{"name":"n","type":"java.lang.Integer","comment":"number of discs"}]},"testCases":[{"input":[6],"output":"45"},{"input":[10],"output":"731"},{"input":[14],"output":"11702"},{"input":[23],"output":"5991862"},{"input":[16],"output":"46811"},{"input":[0],"output":"0"},{"input":[1],"output":"1"},{"input":[2],"output":"2"},{"input":[631],"output":"6365012022352392883148955923130986781380062091585602581723203847515729864967462871799543542574457867994757686347090411984777768863526001671669449385773178276021197927399923200450438326236891"},{"input":[632],"output":"12730024044704785766297911846261973562760124183171205163446407695031459729934925743599087085148915735989515372694180823969555537727052003343338898771546356552042395854799846400900876652473782"},{"input":[972],"output":"28512004421924568737948181614811979515249303720506536307179246320531598455270915225499399507037652872704892097774178503485320542691337052296273882832640448861714366756444081093107681734919471245466476524922056057047583006501726719841269360977829202250101727241082229166319407074719200141826925"}]},
{"id":"insert-at-head","title":"Insert Node at Head","description":"Write a method `insertAtHead` to insert a node at the front of a singly linked list. Return the head of the modified list.\n\n### Examples\n\n* `1->2->3->4->5->6, 7` -> `7->1->2->3->4->5->6`","timeLimit":1,"level":1,"func":{"name":"insertAtHead","returnStatement":{"type":"com.jalgoarena.type.ListNode","comment":" Head of modified list (ListNode)"},"parameters":[{"name":"head","type":"com.jalgoarena.type.ListNode","comment":"Linked List head"},{"name":"data","type":"java.lang.Integer","comment":"New value"}]},"testCases":[{"input":[[1,2,3,4,5,6],7],"output":[7,1,2,3,4,5,6]},{"input":[[],2],"output":[2]},{"input":[[1],1],"output":[1,1]},{"input":[[5,3],5],"output":[5,5,3]}]},
{"id":"unique-characters","title":"Unique Characters","description":"Write a method `uniqueCharacters` to find all unique characters within input string.\n\n> * Input string has to be sorted in lexical order.\n> * You always have to return string\n> * Remove non-letters & non-numbers\n\n### Examples\n\n* `aaabacdefilcskad` -> `abcdefikls`\n* `a0` -> `0a`","timeLimit":1,"level":1,"func":{"name":"uniqueCharacters","returnStatement":{"type":"java.lang.String","comment":"Sorted string"},"parameters":[{"name":"input","type":"java.lang.String","comment":"Input string"}]},"testCases":[{"input":["aaabacdefilcskad"],"output":"abcdefikls"},{"input":["a"],"output":"a"},{"input":[null],"output":""},{"input":[""],"output":""},{"input":["dasld;alaw78&*&sdsa)909as"],"output":"07899adlsw"},{"input":["ddcbbaaddc"],"output":"abcd"},{"input":["ddcbbaaddZDc"],"output":"DZabcd"}]},
{"id":"unique-characters","title":"Unique Characters","description":"Write a method `uniqueCharacters` to find all unique characters within input string.\n\n> * Input string has to be sorted in lexical order.\n> * You always have to return string\n> * Remove non-letters & non-numbers\n\n### Examples\n\n* `aaabacdefilcskad` -> `abcdefikls`\n* `a0` -> `0a`","timeLimit":1,"level":1,"func":{"name":"uniqueCharacters","returnStatement":{"type":"java.lang.String","comment":"Sorted string"},"parameters":[{"name":"input","type":"java.lang.String","comment":"Input string"}]},"testCases":[{"input":["aaabacdefilcskad"],"output":"abcdefikls"},{"input":["a"],"output":"a"},{"input":[null],"output":""},{"input":[""],"output":""},{"input":["dasld;alaw78&*&sdsa)909as"],"output":"0789adlsw"},{"input":["ddcbbaaddc"],"output":"abcd"},{"input":["ddcbbaaddZDc"],"output":"DZabcd"}]},
{"id":"replace-spaces","title":"Replace all Spaces","description":"Write a method `replaceSpaces` to replace all spaces in string with a given replacement string.\n\n> * You cannot use the built-in `String.replaceAll()` or similar!\n> * Always return a string\n\n### Examples\n\n* `Some test, *` -> `Some*test`","timeLimit":1,"level":1,"func":{"name":"replaceSpaces","returnStatement":{"type":"java.lang.String","comment":"Replaced string"},"parameters":[{"name":"a","type":"java.lang.String","comment":"Input string"},{"name":"b","type":"java.lang.String","comment":"Replacement string"}]},"testCases":[{"input":["Some test","*"],"output":"Some*test"},{"input":["Some longer test","!!"],"output":"Some!!longer!!test"},{"input":[null,"*"],"output":""},{"input":["*",null],"output":"*"},{"input":["* *",null],"output":"**"},{"input":["* *",""],"output":"**"}]},
{"id":"is-int-palindrome","title":"Is Int Palindrome","description":"Write a method `isIntPalindrome` that checks if a given integer is a `palindrome` - without allocating additional heap space!\n\n### Examples\n\n* `-1` -> `false`\n* `0` -> `true`\n* `121` -> `true`","timeLimit":1,"level":1,"func":{"name":"isIntPalindrome","returnStatement":{"type":"java.lang.Boolean","comment":" Indicate if int is a palindrome"},"parameters":[{"name":"x","type":"java.lang.Integer","comment":"int to be checked if it is palindrome"}]},"testCases":[{"input":[-1],"output":false},{"input":[0],"output":true},{"input":[121],"output":true},{"input":[11111121],"output":false},{"input":[5123215],"output":true}]},
{"id":"find-node-without-recursion","title":"Find Node Without Recursion","description":"Given a `binary tree`, write a method `findWithoutRecursion` to find node with a given value.\n\n> * `Do not use recursion`!\n> * Return `null`, if desired node is not found\n\n### Example\n\n ```\n 1\n / \\\n 2 3 , 5 ==> TreeNode(5)\n / \\ / \\\n 4 5 6 7 \n```","timeLimit":1,"level":2,"func":{"name":"findWithoutRecursion","returnStatement":{"type":"com.jalgoarena.type.TreeNode","comment":"Element we are looking for"},"parameters":[{"name":"root","type":"com.jalgoarena.type.TreeNode","comment":"Root of binary tree (TreeNode)"},{"name":"val","type":"java.lang.Integer","comment":"Value to find"}]},"testCases":[{"input":[{"data":1,"left":{"data":2,"left":{"data":4},"right":{"data":5}},"right":{"data":3,"left":{"data":6},"right":{"data":7}}},5],"output":{"data":5}},{"input":[{"data":1,"left":{"data":2,"left":{"data":4},"right":{"data":5}},"right":{"data":3,"left":{"data":6},"right":{"data":7}}},2],"output":{"data":2,"left":{"data":4},"right":{"data":5}}},{"input":[{"data":1,"left":{"data":2,"left":{"data":4},"right":{"data":5}},"right":{"data":3,"left":{"data":6},"right":{"data":7}}},10],"output":null},{"input":[{"data":1,"left":{"data":2,"left":{"data":4}},"right":{"data":3,"right":{"data":7,"left":{"data":6}}}},4],"output":{"data":4}},{"input":[{"data":1},2],"output":null},{"input":[null,1],"output":null}]},
Expand Down

0 comments on commit f816bd9

Please sign in to comment.