Skip to content

Commit

Permalink
frq 2017 + 2015
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitd3 committed Apr 28, 2023
1 parent a3135ed commit 958aa4d
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions _notebooks/2023-04-27-frqpractice2017.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,70 @@
"}\n",
"Position.main(null);"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"16\n",
"16\n",
"32\n",
"28\n",
"20\n"
]
}
],
"source": [
"public class ArrayManipulation{\n",
"\n",
" public static int arraySum(int[] arr){\n",
" int arraySum = 0;\n",
" for(int i = 0; i < arr.length; i++){\n",
" // System.out.println(\"array sum: \" + arraySum);\n",
" // System.out.println(\"arr i \"+ arr[i]);\n",
"\n",
" arraySum += arr[i];\n",
"\n",
" }\n",
" System.out.println(arraySum);\n",
" return arraySum;\n",
" }\n",
"\n",
" public static int[] rowSums(int[][] arr2D){\n",
" int rowSum;\n",
" int[] rowSumS = new int[arr2D.length];\n",
"\n",
" for(int i = 0; i < arr2D.length; i++){\n",
" rowSum = 0;\n",
" for(int h = 0; h < arr2D[i].length; h++){\n",
" rowSum += arr2D[i][h];\n",
" }\n",
" rowSumS[i] = rowSum;\n",
" System.out.println(rowSumS[i]);\n",
" }\n",
" return rowSumS;\n",
" }\n",
"\n",
" public static void main(String[] args){\n",
" int[] arr = {1, 3, 2, 7 ,3};\n",
" ArrayManipulation.arraySum(arr);\n",
"\n",
" int[][] arr2D = {{1, 3, 2, 7 ,3}, {10, 10, 4, 6, 2}, {5, 3, 5, 9 ,6 }, {7,6,4,2,1}};\n",
" ArrayManipulation.rowSums(arr2D);\n",
" } \n",
"\n",
"}\n",
"ArrayManipulation.main(null);"
]
}
],
"metadata": {
Expand Down

0 comments on commit 958aa4d

Please sign in to comment.