Java no miltiply/divide in cycle solution (7ms, beats 100%)
Intuition\nJust remove multiplication and division in cycle and you get sugnificant speed gain\n Describe your first thoughts on how to solve this problem. \n\n
# Intuition\nJust remove multiplication and division in cycle and you get sugnificant speed gain\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String decodeCiphertext(String encodedText, int rows) {\n        if (encodedText.isEmpty()) return "";\n        if (rows == 1) return encodedText;\n        int size = encodedText.length();\n        int cols = encodedText.length() / rows;\n        int oneMinusRows = 1 - rows;\n        char[] decoded = new char[size];\n        int decodedPosBase = 0;\n        for (int c = 0; c < cols; c++) {\n            int encodedPos = c;\n            int decodedPos = decodedPosBase;\n            for (int r = 0; r < rows; r++) {\n                if (decodedPos < 0) break;\n                if (decodedPos < size) {\n                    decoded[decodedPos] = encodedText.charAt(encodedPos);\n                }\n                encodedPos += cols;\n                decodedPos += oneMinusRows;\n            }\n            decodedPosBase += rows;\n        }\n        int j = decoded.length - 1;\n        while (decoded[j] == \' \' || decoded[j] == 0) j--;\n        return String.copyValueOf(decoded, 0, j + 1);\n    }\n}\n```
['Java']