A simple program that can quickly generate test data for various data structures in LeetCode format.
This repository is still under development! All available features can be checked in main.html
or Table of Contents (titles with link).
Choose any method to download this repository:
-
Clone via HTTPS
git clone https://github.com/HandianYang/leetcode-testcase-generator.git
-
Clone via SSH
git clone git@github.com:HandianYang/leetcode-testcase-generator.git
-
Download ZIP
- Open
main.html
in any of your favored browser. - Select the tab below the "LeetCode Testcase Generator" title.
- Enter the corresponding content in each field.
- Click
Generate
button below the fields. - Click
Copy
button to copy the generated test case to clipboard. Note that you can only copy the text if your inputs are valid.
- Basics
- One-dimensional array
- Numerical array
- Monotonic numerical array
- Character array
- String array
- Two-dimensional array
- Numerical matrix
- Character matrix
- Strings
- Normal String
- String with words seperated by spaces
- One-dimensional array
- Data Structures
- Tree
- Binary tree
- Balanced binary tree
- Binary search tree
- N-ary tree
- Graph
- Unweighted graph
- Weighted graph
- Tree
- Others
- Design problem
Generate a randomized numerical array in integer type. Each element in the array is randomly selected from a given numerical range.
Problems regarding (but not limited to) ...
- 1D numerical array (
Array
) - linked-list (
Linked List
,Doubly-Linked List
)
You should not use this function to generate test cases of ...
- 1D SORTED array (use Monotonic numerical array instead)
- binary tree (use "Normal binary tree" or other specific trees instead)
lowerBound (int)
: The lower bound of the range. The number MAY NOT be included in the output array.upperBound (int)
: The upper bound of the range. The number MAY NOT be included in the output array.length (int)
: The length of the output array.
- Do not leave blank, or type any non-numerical symbols into any input field.
length
must be a non-negative number.lowerBound
must not be greater thanupperBound
.
Generate a randomized numerical array in integer type, with elements listed in increasing/decreasing order. Each element in the array is randomly selected from a given numerical range.
Problems regarding (but not limited to) ...
lowerBound (int)
: The lower bound of the range. The number MAY NOT be included in the output array.upperBound (int)
: The upper bound of the range. The number MAY NOT be included in the output array.length (int)
: The length of the output array.type (option)
: The monotonic type of the array, with 4 options "non-decreasing", "non-increasing", "strictly increasing", and "strictly decreasing".
- Do not leave blank, or type any non-numerical symbols into any input field.
length
must be a non-negative number.lowerBound
must not be greater thanupperBound
.- For strictly monotonic series, the length of
[lowerbound, upperbound]
must not be smaller than the length of the array.
Generate a randomized numerical matrix (i.e. 2D array) in integer type. Each element in the matrix is randomly selected from a given numerical range.
Problems regarding (but not limited to) ...
- matrix (
Matrix
)
lowerBound (int)
: The lower bound of the range. The number MAY NOT be included in the output matrix.upperBound (int)
: The upper bound of the range. The number MAY NOT be included in the output matrix.row (int)
: The number of rows of the output matrix.col (int)
: The number of columns of the output matrix.
- Do not leave blank, or type any non-numerical symbols into any input field.
row
andcol
must be non-negative numbers.lowerBound
must not be greater thanupperBound
.
Generate a string of randomized characters. Each character is randomly selected from the given range and type, such as uppercase and lowercase letters, numbers, and other common symbols.
Problems regarding (but not limited to) ...
length (int)
: The length of the output string.type (option) & range (string)
: The character type that the output string MAY contain. Each option can be selected by checking the corresponding checkbox, and the range of covered characters can also be specified.uppercase
: The uppercase letters, ranging fromA
toZ
(if not specified).lowercase
: The lowercase letters, ranging froma
toz
(if not specified).number
: The character of digits, ranging from0
to9
(if not specified).other symbol
: Other common symbols to be specified, such as.
,,
. However, you can type letters and digits as well (refer to Input format).
The following inputs of range
are acceptable:
- Leave blank: all characters of that type are covered.
- (e.g.) Below specifies that all uppercase and lowercase letters are covered.
[v] uppercase letters () [v] lowercase letters () [ ] numbers [ ] other symbols
X
: only the character of that type is covered.
- (e.g.) Below specifies that
A
and all digits are covered.[v] uppercase letters (A) [ ] lowercase letters [v] numbers () [ ] other symbols
X-
/-X
: all characters after/beforeX
(inclusive) of that type are covered.
- (e.g.) Below specifies that
a-c
and2-9
are covered. Note that the number begins with0
, so the input2-
represents23456789
rather than234567890
. Similarly, the input-3
represents0123
instead of123
.[ ] uppercase letters [v] lowercase letters (-c) [v] numbers (2-) [ ] other symbols
- (e.g.) Below specifies that
A
and9
are covered. Here,-A
is equal toA
, and9-
is equal to9
.[v] uppercase letters (-A) [ ] lowercase letters [v] numbers (9-) [ ] other symbols
X-Y
/XY
orY-X
/YX
: all characters fromX
toY
(inclusive) are covered. The reversed range is acceptable as well.
- (e.g.) Below specifies that
A-E
,x-z
, and2-4
are covered. Here,4-2
is the same as2-4
.[v] uppercase letters (A-E) [v] lowercase letters (xz) [v] numbers (4-2) [ ] other symbols
- (e.g.) Below specifies that
G
andy
are covered. Here,G-G
is the same asG
, andyy
is the same asy
.[v] uppercase letters (G-G) [v] lowercase letters (yy) [ ] numbers [ ] other symbols
The following explains the format of other symbol
:
- Type all covered symbols consecutively.
- (e.g.) Below specifies that
.
,/
, and all lowercase letters are covered. Note that the duplicated characters will be ignored. Specifically, the duplicated characters will not affect the probability of being selected.[ ] uppercase letters [v] lowercase letters () [ ] numbers [v] other symbols ( .///)
- Type letters and/or digits if the desired range of any type is discontinuous.
- (e.g.) Below specifies that
A-F
,I
,O
, andU
are covered. SinceA
andE
are already specified at the uppercase letters option (A-F
), they are considered duplicated, and thus should be ignored.[v] uppercase letters (A-F) [ ] lowercase letters [ ] numbers [v] other symbols (AEIOU)
- (e.g.) Below specifies that all odd digits are covered.
[ ] uppercase letters [ ] lowercase letters [ ] numbers [v] other symbols (13579)
- Do not leave blank, or type any non-numerical symbols into the
length
field. length
must be a non-negative number.- Select at least one option of
type
. - Do not type characters into mismatch fields.
- (WRONG)
[v] numbers (A-C)
- (WRONG)
[v] uppercase letters (De)
- Use
-
carefully and correctly.
- (WRONG)
[v] lowercase letters (-)
- (WRONG)
[v] lowercase letters (--)
- (WRONG)
[v] lowercase letters (--e)
- Do not type any irrelevant characters, except for
other symbol
.
- (WRONG)
[v] lowercase letters (p,q,r)
- (WRONG)
[v] numbers (1~3)
- (WRONG)
[v] numbers (7/9)
- Do not type more than two characters (
-
does not count) inrange
, except forother symbol
.
- (WRONG)
[v] lowercase letters (cdefg)
- (WRONG)
[v] numbers (1-34)