you give nested list integer nestedlist each element integer list element integer list Implement iterator flatten itImplement NestedIterator classnestediteratorlistnestedinteger nestedlist Initializes iterator nest list nestedListint Returns integer nest listboolean hasnext return true integer nest list false otherwiseYour code test follow pseudocodeinitialize iterator nestedlistre iteratorhasnext append iteratornext end resreturn resIf re match expect flatten list code judge correct Example 1input nestedlist 11211output 11211explanation by call repeatedly hasnext return false order element return 11211example 2input nestedlist 146output 146explanation by call repeatedly hasnext return false order element return 146 Constraints1 nestedlistlength 500the value integer nest list range 106 106