Cardiac arrhythmia is one of the most critical cardiovascular diseases that cause millions of fatalities every year. Early detection of the disease by analyzing the electrocardiogram signals of patients has the potential to save many lives. Deep learning prediction models have gained a lot of attention for arrhythmia prediction. Among them, convolutional neural network (CNN) and long short-term memory (LSTM) techniques are widely used. These models have been recently combined into the CNN-LSTM model to achieve high accuracy and efficiency in arrhythmia prediction. However, there is a lack of studies analyzing the performance of CNN and CNN-LSTM techniques to find the optimal values for key parameters such as the number of filters, kernel size, and layers. This article determines optimized CNN (OCNN) and optimized CNN-LSTM (OCNN-LSTM) models for MIT-BIH arrhythmia datasets by analyzing the models' performance by varying several key parameters. Performance is measured in terms of accuracy, AUC, recall, precision, and specificity. Hence, the aim is to find the optimum values for the key parameters required to develop deep learning models for the MIT-BIH arrhythmia dataset. The finest outcomes attained for the OCNN and OCNN-LSTM models were 99.9% and 98.1% AUC, 99.0%, 96.1% accuracy, 98.5% and 93.3% recall, 98.1%, and 93.5% precision, and 99.2% and 97.2% specificity, respectively.