#Help!

16 messages · Page 1 of 1 (latest)

jagged rampartBOT
#

This post has been reserved for your question.

Hey @fringe shuttle! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

fringe shuttle
#

@old notch

limpid oxide
#

please do not ping people who are not actively helping you, for help

limpid oxide
#

please do not spoonfeed

#

just like before, first figure out how many elements you need in each resulting array
loop with 2 separate variables to create the new array

fringe shuttle
#

yeah i fixed it ft

#

ty

lyric sun
#

Do not copy

lyric sun
lyric sun
fringe shuttle
# lyric sun Please send your solution
        for (int i = 0; i < array.length; i++) {
            int elemsFound = 0;

            for (int j = 0; j < array[i].length; j++) {
                if (array[i][j] == elem) {
                    elemsFound++;
                }
            }

            if (elemsFound == 0) {
                continue;
            }

            int[] newRow = new int[array[i].length + elemsFound * (newElem.length - 1)];

            int k = 0;
            int l = 0;
            for (int j = 0; j < array[i].length; j++) {
                if (array[i][j] == elem) {
                    for (int m = 0; m < newElem.length; m++) {
                        newRow[k] = newElem[m];
                        k++;
                    }
                    l++;
                } else {
                    newRow[k] = array[i][j];
                    k++;
                }
            }

            array[i] = newRow;
        }
        return array;
    }```
#

i completely rewrote it

#

@lyric sun how did u fix my old code?

#

my old code was very messy to me and it was hard to understand

lyric sun
#

Please close the issue/post